Quantcast
Channel: Snippets Archives - Gravity Wiz
Viewing all articles
Browse latest Browse all 196

Notify User When Submitted Post is Published

$
0
0

This handy snippet allows you to send an email notification to the user who submitted a Gravity Forms generated post when that post is published.

View this code snippet on GitHub.

This snippet assumes you have created a Post Custom Field which will store the submitting user’s email address. You would then specify the “Custom Field Name” you specified for the field as the $custom_field_name variable.

For example, assuming I had configured a Post Custom Field with the following settings:

Sample Post Custom Field settings configured as an email field

I would set the $custom_field_name variable like so:

View this code snippet on GitHub.

Lastly, don’t forget to set your basic email settings!

View this code snippet on GitHub.
This will only work for regular WordPress posts. If you’d like to apply to pages (or any custom post type), you’ll want to update the action from “publish_post” to “publish_{your_post_type}”.

Viewing all articles
Browse latest Browse all 196