Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add a function when a user recieves a notification ?

  • @mahdiar

    Participant

    Hi

    The following code is my function to send sms when a new post published . I’d like to change it to send sms to user when a he/she has a new notification .
    How can I do that ?
    I’m using wp-sms plugin .

    function send_sms_when_subscribe_new_user() {
        global $sms;
        $sms->to = array('123456789');
        $sms->msg = "Hi USER, New Post !";
        $sms->SendSMS();
    }
    add_action('publish_post', 'send_sms_when_subscribe_new_user', 10, 2);

    123456789 = user phone number (It’s a profile field )
    User = User’s name

Viewing 2 replies - 1 through 2 (of 2 total)
  • @shanebp

    Moderator

    Look at
    class BP_Notifications_Notification
    function save
    in
    buddypress\bp-notifications\bp-notifications-classes.php

    There are 2 hooks you can use to add_action
    bp_notification_before_save or bp_notification_after_save

    @mahdiar

    Participant

    Thanks .It works.
    Excuse me I don’t know how to use hooks . Could you please explain how can I use user phone number in “$sms->to”?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add a function when a user recieves a notification ?’ is closed to new replies.
Skip to toolbar