Home › Forums › Calendar Products › Community Events › Notify event's author by email after his event is approved by admininstrator
- This topic has 5 replies, 2 voices, and was last updated 11 years, 5 months ago by
Brook.
-
AuthorPosts
-
November 18, 2014 at 3:42 am #888915
louisecote
ParticipantHello.
I need to notify users by email, when their events are approved by admin. I’m ready to make changes to plugins code or use any useful hook, if you kindly give me some instructions.
P.S. Is there any way to replace a link in notification email sent to admin, when user sumbits a new event? I want to have link that leads to backend (e.g. /wp-admin/post.php?post=5177&action=edit), not to frontend, because it’s important to have an opportunity not to approve a new event and remove it completely.November 18, 2014 at 7:08 am #889085Brook
ParticipantHowdy louisecote,
That’s a really neat idea. I think it will be easy enough to do. You could tap into the save_post action of WordPress. This fires every time a post is saved or updated. So we will need to check if the post is from Community Events. You can do this by checking for the meta value “_EventOrigin”, if it equals “community-events” then you have yourself what you’re looking for. From there you could check and see if the event is now live and if your custom meta key, perhaps something like “_EventSubmitterNotified” is true. If not, send an email.
WordPress has some built-in mail functionality you could use to send an email. Of course it will be up to you to style it and such how you please.
Does that all make sense? Sound like what you are looking for? Please let me know if you have questions!
– Brook
November 19, 2014 at 2:40 am #890323louisecote
ParticipantThanks. I’ve created a function called on save_post event. But I have following problem now. If admin approves event in dashboard, everything is fine, but the problem is that he gets notification email with a link to frontend event edit page, and if admin clicks Submit button, he becomes the author of this event and this Event has pending status. Can we replace a link in admin notification email with a link to backend? For example, to use /wp-admin/post.php?post=5184&action=edit instead of /events/community/edit/event/5184/
November 19, 2014 at 8:09 am #890652Brook
ParticipantCool! That’s a great modification.
The email template that is used for that particular emails is: wp-content/plugins/the-events-calendar-community-events/views/community/email-template.php. If you create a theme override for it you can change the section where it echoes the permalink to the backend edit link instead. The best way to get that link is via the function admin_url().Checkout the function get_edit_post_link() in WP Core for an example of how to build the URL you are looking for using admin_url(). Ordinarily get_edit_post_link() would be the function you would need, but it only returns a value if the current user is an admin. Which generally is not the case for community event submitters.
Did that work? Cheers!
– Brook
November 20, 2014 at 1:41 am #891760louisecote
ParticipantThanks for great assistance. You can close this thread.
November 24, 2014 at 2:21 pm #897497Brook
ParticipantAwesome! Glad that helped.
– Brook
-
AuthorPosts
- The topic ‘Notify event's author by email after his event is approved by admininstrator’ is closed to new replies.
