Notify Author When Post is Published
This snippet is almost identical to the Notify User When Submitted Post is Published snippet. The key difference is this will send a notification to post author rather than an email stored in a custom field. This approach is only applicable when a) logged in users are creating posts via a Gravity Form or b) the Gravity Forms User Registration Add-on is being to used to register a user and a post is being created by that user from the same form.
In case you were wondering… the Gravity Forms User Registration Add-on provides an option to set the registered user as the post author. Convenient, eh?
Don’t forget to set your basic email settings. This includes the name and email from which the email should be sent as well as the subject and message of the notification email.
$from_name = 'Your Name';
$from_email = 'your@email.com';
$subject = 'Your Subject Here';
$message = 'Your message here.';
Is this still working?
As for me, it is not… ;-(
Is it a Problem to use a Plugin like Post SMTP and having enabled other Plugins are not allowed to change sender-name or email (but I have set it to the same).
Hi Marius,
I just tested the snippet and can confirm that it works when a Post is created using Gravity Forms Post fields. I also tested it with Post SMTP, and it worked as expected. I will be following up with you via email to request more information and have a closer look at your setup.
Best,
Hi there,
I tried using this plugin, but it’s not sending the email.
Is there anything I need to change for it to work with Woocommerce Products created via Gravity Forms using the Custom Post Types addon?
Your help is greatly appreciated.
I wouldn’t think so. A post is a post as far as Gravity Forms is concerned. I’m wondering if the “_gform-form-id” meta key is being added. Could you check? Add this to your theme’s functions.php via FTP (do not add this via the theme editor).
echo ‘‘;
Replace “$post_id” with the ID of your post. You’ll need to view the source to see the output as it is wrapped in an HTML comment.
I can’t find a way to approve submitted posts so that they appear. What am I missing?
Hi Erika, you can “approve” posts by publishing them via WordPress’ Posts menu. You’ll want to find the post in question, click on it to edit, and then hit the publish button once you’re satisfied. :)
Hi,
Is it possible to email the user a link to the published post?
Thanks for snippet, it’s great.
Yes, it is. You can either send them a URL like so:
http://yoursite.com/?p={post_id}
Or you can use this snippet to add support for a {post_permalink} merge tag.
https://gist.github.com/spivurno/c87eab3aa56a5c6bded1
THanks David. That works.
One other problem.. the Sender field when received by the recipient reads:
name rnContent-type: text/html; charset…. etc etc
How can I get this to just read name ?
Thanks
This sounds like more of an issue you’re having with WordPress’ wp_mail() than this snippet. Are you seeing this with other emails you receive from WordPress or Gravity Forms?
What file do I put this in? I put it into my theme’s functions.php and it fails to run. Nice work! (I just need a little prompt for where it goes….)
Hi steveO, just want to confirm that you followed the instructions here.
With that said, you might be interested in the GP Post Status Notifications perk available (by request, it’s a beta) with Gravity Perks. Here is a quick video that demonstrates how it works. I think you’ll really appreciate how much easier and more powerful the perk-version is compared to this snippet.
is there a better way? if you fire it on publish_post that means it will be fired on every post submit, non gravityforms wise.
Gravity Forms adds a post meta value to the field stored as “_gform-form-id”. This snippet checks for the existence of this meta key. If it isn’t found, it knows this post was not created by a Gravity Form and does not send the email.