[Résolu] How to send auto notifications when deleting a post via CRED form
This support ticket is created Il y a 8 années et 7 mois. 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.
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.
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.
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
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.
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
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?