Skip Navigation

[Resuelto] How to send auto notifications when deleting a post via CRED form

This support ticket is created hace 8 años, 9 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Etiquetado: 

This topic contains 30 respuestas, has 3 mensajes.

Last updated by jamesH-3 hace 8 años, 7 meses.

Assisted by: Shane.

Autor
Mensajes
#285953

Hi

I am using a CRED form delete content link (cred_delete_post_link) and I would like to be able send an auto notification to when this link is used and preferably with the deleted content included in the email.

Can you please direct me in the right direction?

I could not find any information on this on the Forum.

Thanks

#286078

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Since this is not a function that is in our CRED form at the moment.

This can however be achieved by using a very basic custom hook.

Please see the function below.

add_action('trash_post','my_trash_post_function',1,1);
function my_trash_post_function($post_id){

		$deleted_post = get_post($post_id);
		$content = $deleted_post->post_content;
   
         $headers = 'From: My Name <myname@example.com>' . "\r\n";
   		wp_mail('test@gmail.com', 'A new Post has be Deleted', $content, $headers);
    
}

Add this to your theme's function.php file and it will send a mail anytime a post is deleted.

#286390

Hi Shane

I am really sorry but I am not very good, in fact very bad, with coding.

How should I amend this code:

1- for the subject line of the email to say something like "Your Deleted Coupon - %%POST_TITLE%% - Coupon Number: %%POST_ID%%"

2- for the content of the email to

a - show only some of the CRED fields, instead of the full content, such as "[cred_field field="coupon-condition-1" post="coupon" value="" urlparam=""]"

b- show some additional text with multiple paragraphs, such as "Dear %%USER_LOGIN_NAME%%", "Paragraph1" and "Paragraph 2"

c- to include an image, e.g. "companylogo.png"

4- for the email to be sent to the email address of the Author and cc or bcc'ed to the email address of the admin (Please note this link will be used by individual users and send to email address will change depending on the email address of the logged in user/Author)

5- for this notification to be sent only when a specific custom post was deleted and not every time any post was deleted, e.g only "$coupon" posts of the logged in user/Author

Thanks

#286943

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

What I can provide is a basic email notification hook.

Which is this

add_action('trash_post','my_trash_post_function',1,1);
function my_trash_post_function($post_id){

		$deleted_post = get_post($post_id);

		$id = $deleted_post->id;
		$title = $deleted_post->post_title;
		$content = $deleted_post->post_content;
   		

   		if ($post->post_type == 'my-custom-post-type') {

         $headers = 'From: My Name <myname@example.com>' . "\r\n";
   		wp_mail('user@gmail.com', 'Your Deleted Coupon - {$title} - Coupon Number: {$id}', $content, $headers);
    	}
}

For a more comprehensive code based on your requirements I think it is best that you contact our custom development team.

You can contact them by going here : custom.wp-types.com

They should be able to give a more complete and better solution that I can.

#287318

Hi Shane

I have tried the code you provided but it does not seem to work. It cause delays in deleting the post and does not trigger any emails.

Thanks

add_action('trash_post','my_trash_post_function',1,1);
function my_trash_post_function($post_id){

$deleted_post = get_post($post_id);

$id = $deleted_post->id;
$title = $deleted_post->post_title;
$content = $deleted_post->post_content;

if ($post->post_type == 'coupon') {

$headers = 'From: My Name <xyz@gmail.com>' . "\r\n";
wp_mail('xyz@outlook.com', 'Your Deleted Coupon - {$title} - Coupon Number: {$id}', $content, $headers);
}
}

#287372

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

You in order for the email notifications to be sent you need to replace the emails in the code with the appropriate ones.

Right now I see that you have "xyz@gmail.com" and "xyz@outlook.com". I am not sure if these are legitimate emails or not but the issue could be with that.

#287433

In the code I used I used the correct email adresses.

#287607

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Does your wordpress website send out email notifications normally, such as when a post is created or edited?

I would like to check on this but I need to have access to your website.

I will be enabling the private fields so you can supply me with the necessary information.

#288467

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

This seems to be an issue with your hosting provider.

What I need you to do is to check with them to ensure that the correct module for emailing is enabled on the server.

The code for sending the email works for me in a test environment and should work in your production environment.

Please check with them to see if this module is enabled.

Please let me know and we can move from there.

#288623

Hi Shane

I have just been in touch with the support team of the hosting provider.

They told me that you needed to be more specific about what module you wanted them to check.

They have also told me that you could check it yourself from the link below:

hidden link

Thanks

#288775

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Tell them to check the sendmail_path module.

Also could you ask them to verify your the mailing on your website.

Ensure that you can send emails using your wordpress website.

#288777

Hi Shane I ll ask them today but can you please clarify what you mean by 'verify your the mailing on your website'? There may have been a typo there? Thanks

#288782

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Sorry about that.

What I meant is that you should allow them to test your website to see if it can send out emails.

if it can't then the code I provided earlier won't work.

I need to check if emails can be sent 🙂

Please let me know once you have gotten an answer from your hosting company.

#288786

I dont know if it woukd help but I can confirm that when my regisration form (made with Gravity Forms) I do receive an auto email from wordpress@turkeytravelhub.com. does that mean emails can be sent?

#288788

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Thanks for confirming this.

What I can do is to log into your website with the credentials that you had provided to see why this is not work.

Could you check your spam/junk mail to see if there is any mail that could've been generated from your site through the script I sent.

Thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.