• Resolved sarahagordon

    (@sarahagordon)


    We have WPAdverts installed on our site here: https://careyinstitute.org/sourceny/

    I would like to create an email notification for our program manager each time a new listing is created so she can share it in our program email updates. Is there an easy way to do this via the plugin, RSS, or some other means?

    I have a landing page setup with a widget for recent ads here: https://careyinstitute.org/sourceny-recent-ads/. I attempted to set up an rss feed for this page via MailChimp using this link: careyinstitute.org/sourceny-recent-ads/feed/. However, but the 4 published items in the queue do not seem to be translating to something the RSS feed recognizes. This is the message Mailchimp gives —
    “Example RSS Feed Item
    Your feed has not published any items, so we are using this as an example of what a typical post might look like. Please update your RSS feed with some content so you can see a real example of what will be delivered.”

    Any insight you might be able to offer would be extremely helpful. Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    To send an email when Advert is published you can use post transitions, the code below will do that

    
    add_action('publish_advert', on_publish_advert');
    function on_publish_advert($post_id) {
        wp_mail(get_option("admin_email"), "New Advert Published", "Advert with ID $post_id was published");
    }
    
    Thread Starter sarahagordon

    (@sarahagordon)

    Sorry to be dense, but I have 2 follow-up questions:

    1. Is there a way to send it to a separate email than the admin email, like [email protected]?

    2. Where should I insert this snippet of code?

    Thank you so much for your assistance!

    Plugin Author Greg Winiarski

    (@gwin)

    1. yes, just replace get_option("admin_email") with "[email protected]".
    2. you can add it in your theme functions.php file.

    Thread Starter sarahagordon

    (@sarahagordon)

    I put in that code, but now my website has crashed and I am getting this error. Upon removing the code, the issue is not resolved. Can you please help?

    Parse error: syntax error, unexpected ”); ‘ (T_ENCAPSED_AND_WHITESPACE) in /home/lsyelich/public_html/wp-content/themes/themify-landing/custom-functions.php on line 42

    Plugin Author Greg Winiarski

    (@gwin)

    Something in your code is incorrect, please make sure it is

    
    add_action('publish_advert', on_publish_advert');
    function on_publish_advert($post_id) {
        wp_mail("[email protected]", "New Advert Published", "Advert with ID $post_id was published");
    }
    

    When i add this in the theme functions.php i get a blank page?

    Greetings

    Klaus

    Ok, wrong code:

    add_action(‘publish_advert’, on_publish_advert’);

    it has to be

    add_action(“publish_advert”, “on_publish_advert”);

    The email is sent, when a pending ad is published. That might be ok, but it would be better, when the admin gets an email, when an ad i added and still pending so he has to know that there is an ad waiting to be published.

    Any idea how to solve this?

    Greetings

    Klaus

    Plugin Author Greg Winiarski

    (@gwin)

    You can send the same email when advert is saved as pending by adding the additional line below

    
    add_action('pending_advert', 'on_publish_advert');
    

    Works like a charme!

    One is left, Greg. Can we send email notification to more than one email address?

    Plugin Author Greg Winiarski

    (@gwin)

    Yes, just add another wp_mail(...); line in the on_publish_advert() function.

    Great and… outstanding support as well!

    Greetings

    Klaus

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Email notification when new listing is created’ is closed to new replies.