• Resolved gutembergz

    (@gutembergz)


    Hi, Greg – Great plugin you have, congratulations.

    I’m setting up the plugin at my website and most of all are working fine. I’ve bought the add-ons and I’m still learning to deal with it.

    Searching at the forum and the snippets I’ve found the code to notice admins when a new ad is sent and needs approval. Fine!

    But… When the ad is approved, would be good notice to the user. Could you help me at this way? I’m searching and reading all the titles at the support pages. There’s so much help from you and the WP Adverts users…!

    I suggest we can gather the codes to transactional emails or save snippets to help other users – or add a section to Documentation.

    Thanks for your attention!

    I’m using the code below:

    /* sending an e-mail when a new ad is sent and needs approval
    add_action('pending_advert', 'on_pending_advert');
    function on_pending_advert($post_id) {
    	$post_title = get_the_title( $post_id );
    	$edit_post_link = get_edit_post_link( $post_id );
    
    wp_mail(get_option("admin_email"), "New Pending Ad | $post_title", "A new ad with ID $post_id and title $post_title was sent and awaits approval. <p> Follow the link below to moderate it. <p> $edit_post_link  "); 
    }
    
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, i think it is a great idea to have one thread with all the WPAdverts transactional emails, thanks for the suggestion.

    When the advert is approved by administrator its status changes from “pending” to “publish”, so you could use a code like the one below to send the email

    
    add_action('pending_to_publish', 'on_approved_advert');
    function on_approved_advert($post_id) {
        if( get_post_type( $post_id ) != "advert" ) {
            return;
        }
    
        $post_title = get_the_title( $post_id );
        $edit_post_link = get_edit_post_link( $post_id );
    
        wp_mail(
            get_post_meta( $post_id, "adverts_email", true), 
            "Approved Post | $post_title", 
            "A new ad with ID $post_id and title $post_title was sent and awaits approval. <p> Follow the link below to moderate it. <p> $edit_post_link  "
        ); 
    }
    
    Thread Starter gutembergz

    (@gutembergz)

    Great, Greg

    The function is working well until get the advert email. No address is fetched, so the email shows a message “no recipient forward path”.

    I’ve tested the line below with the “Pending E-mail” and it’s running ok:
    get_post_meta( $post_id, “adverts_email”, true)

    And if I want to send the email to the ad author, does it possible?

    Thread Starter gutembergz

    (@gutembergz)

    Listing transactional email possibilities:

    Ad Pending (waiting approval, to admin – above);
    Ad Published (after approval, to user – above);
    Ad Expiring (defined some days before expiration, to user);
    Ad Unpublished (after expiring or due to user/admin exclusion, to user)

    In case of charged ads:

    Ad Awaiting Payment
    Ad Renewing

    I think those specified notifications can’t be done with third part plugins. Maybe a charged addon or native function could be added to this great plugin. Notifications are expected by users that are publishing the ads.

    Thanks for attention!

    Plugin Author Greg Winiarski

    (@gwin)

    Thanks, i will look into creating some code snippet which will allow to cover all the cases when an email should be sent, in the meantime:

    – Ad Expiring – this is more difficult than other as it will require some custom programming
    – Ad Unpublished – expired_advert or publish_to_expired should do it for Ads which expired, the email however will not be sent if Ad was removed deleted or changed to draft by Admin.

    As for payments i assume you are using the bundled Payments module (not WooCommerce integration).

    – Ad Awaiting Payment – advert-pending_advert, or if you wish to get information about the payment itself pending_adverts-payment (then the $post_id) will be an ID of a payment post.

    – Ad Renewing – similarly as above

    Thread Starter gutembergz

    (@gutembergz)

    Thank you, Greg. I’ll set up the last one that I’m needing for now — the Ad Unpublished Transactional E-mail.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Transactional E-mails’ is closed to new replies.