• Resolved wang0516

    (@wang0516)


    I really like this plugin. Thank you for your work.
    Currently I want to send SMS notifications at the same time as sending email notifications. How can I call a custom notification function?
    Looking forward to your reply. Thank you!

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

    (@gwin)

    Hi,
    which email(s) do you mean?

    Usually, the best way to trigger some additional actions when Ad is saved in the database is to use the Post Status Transitions https://codex.ww.wp.xz.cn/Post_Status_Transitions

    For example if you want to send some notification when Advert is pending or published you can use the below code

    
    add_action( "pending_advert", function( $post_id ) {
      wp_mail( get_option( "admin_email" ), "Ad is pending", "Ad is pending" );
    } );
    add_action( "publish_advert", function( $post_id ) {
      wp_mail( get_option( "admin_email" ), "Ad published", "Ad published" );
    } );
    
    Thread Starter wang0516

    (@wang0516)

    Thank you for your help.
    I want to send a text message to the contact number in the advertisement to notify the user that the advertisement is about to expire. This is more timely and effective.

    Send SMS function is like this:

    function sendSms($adverts_phone,$adverts_person,$post_title)
    {
    ....
    }

    How can I call it correctly?

    Plugin Author Greg Winiarski

    (@gwin)

    You can send a text message when an Ad changes status from publish to expire with the below code

    
    add_action( "publish_to_expire", function( $advert ) {
      $adverts_phone = get_post_meta( $advert->ID, "adverts_phone", true );
      $adverts_person = get_post_meta( $advert->ID, "adverts_person", true );
      $post_title = $advert->post_title;
      sendSms($adverts_phone,$adverts_person,$post_title)
    } );
    
    Thread Starter wang0516

    (@wang0516)

    Thank you for your help. I wish you well!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to add a custom notification method?’ is closed to new replies.