Support » Plugin: Ultimate Member - User Profile & Membership Plugin » Send welcome sms via API to newly registered user via signup form

  • Resolved dineshshete

    (@dineshshete)


    Hello everyone.

    I am using UM signup form in my site, I want welcome sms to be sent to registered user ( i am taking mobile number in form). After completing sign up process.

    I have php api for from my bulk sms provider. Can anyone please help me where to put that and how to use meta tags ( mobile number, name, user id, selected user role) in sms .

    Using textlocal for sms.

    Api for php :

    <?php
    // Authorisation details.
    $username = “myemail@gmail.com”;
    $hash = “66ade0f0c30253145b390866621d163eccbd52181466b0205aee7ba2e6d9ea82”;

    // Config variables. Consult http://api.textlocal.in/docs for more info.
    $test = “0”;

    // Data for text message. This is the text message data.
    $sender = “TXTLCL”; // This is who the message appears to be from.
    $numbers = “910000000000”; // A single number or a comma-seperated list of numbers
    $message = “This is a test message from the PHP API script.”;
    // 612 chars or less
    // A single number or a comma-seperated list of numbers
    $message = urlencode($message);
    $data = “username=”.$username.”&hash=”.$hash.”&message=”.$message.”&sender=”.$sender.”&numbers=”.$numbers.”&test=”.$test;
    $ch = curl_init(‘http://api.textlocal.in/send/?&#8217;);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch); // This is the result from the API
    curl_close($ch);
    ?>

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

Viewing 1 replies (of 1 total)
  • SuitePlugins

    (@suiteplugins)

    @dineshshete

    You want to add your code through a hook. So your code should look more like this

    function send_sms_after_registration( $user_id = 0 ) {
            // Authorisation details.
            $username = “myemail@gmail.com”;
            $hash = “66ade0f0c30253145b390866621d163eccbd52181466b0205aee7ba2e6d9ea82”;
    
            // Config variables. Consult http://api.textlocal.in/docs for more info.
            $test = “0”;
    
            // Data for text message. This is the text message data.
            $sender = “TXTLCL”; // This is who the message appears to be from.
            $numbers = “910000000000”; // A single number or a comma-seperated list of numbers
            $message = “This is a test message from the PHP API script.”;
            // 612 chars or less
            // A single number or a comma-seperated list of numbers
            $message = urlencode($message);
            $data = “username=”.$username.”&hash=”.$hash.”&message=”.$message.”&sender=”.$sender.”&numbers=”.$numbers.”&test=”.$test;
            $ch = curl_init(‘http://api.textlocal.in/send/?’);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $result = curl_exec($ch); // This is the result from the API
            curl_close($ch);
    } 
    add_action( 'um_registration_complete', 'send_sms_after_registration', 12, 1 )

    I am not familiar with the API but here are few suggestions. Use wp_remote_post instead of CURL. You can use the $user_id with the function get_user_by to get user details or pull what you need from the user meta table.

Viewing 1 replies (of 1 total)
  • The topic ‘Send welcome sms via API to newly registered user via signup form’ is closed to new replies.