• Resolved wpquestions2018

    (@wpquestions2018)


    Hi Greg,

    How can wordpress/ website send an email immediately an ad expires to the person who posted it automatically even if they are not registered on the website

    The page I need help with: [log in to see the link]

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

    (@gwin)

    Hi, you can do that by adding the code below in your theme functions.php file

    
    add_action( "advert_expired", "on_advert_expired" );
    function on_advert_publish( $post_id ) {
        $to = get_post_meta( $post_id, "adverts_email", true );
        $advert = get_post( $post_id );
        wp_mail( $to, "Ad Expired", sprintf( "Your ad %s has expired", $advert->post_title ) );
    }
    
    Thread Starter wpquestions2018

    (@wpquestions2018)

    Hi Greg,

    Its not working and getting below error

    “Your PHP code changes were rolled back due to an error on line 620 of file wp-content/themes/delivery-lite/functions.php. Please fix and try saving again.

    Cannot redeclare on_advert_publish() (previously declared in wp-content/themes/delivery-lite/functions.php:609)”

    I am getting the error because I am using the Ad published notification and line 609 is
    “function on_advert_publish( $post_id ) {

    The line is repeated for ad published and expired notifications

    Plugin Author Greg Winiarski

    (@gwin)

    Change function on_advert_publish( $post_id ) { to function on_advert_expired( $post_id ) {.

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Hi Greg,

    Is this line correct

    add_action( “advert_expired”, “on_advert_expired” );

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, it most likely should be

    
    add_action( "expired_advert", "on_advert_expired" );
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Expired ads’ is closed to new replies.