Created
July 23, 2026 11:43
-
-
Save hazratbilal0079/67a0d4d1018939583d2d05c39428b75f to your computer and use it in GitHub Desktop.
Gist to send message from Jet form builder to Mobile using httpsms API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('jet-form-builder/custom-action/send_httpsms', function ( $request, $action_handler ) { | |
| $lead_id = isset($request['inserted_post_id']) ? sanitize_text_field($request['inserted_post_id']) : ''; | |
| $phone_no = isset($request['responsible-person-phone']) ? sanitize_text_field($request['responsible-person-phone']) : ''; | |
| // Ensure the phone number retains its '+' prefix if it exists | |
| $phone_no = trim($phone_no); | |
| $httpsms_api_key = 'Your Httpssms APi KEY'; | |
| $httpsms_from_number = 'your mobile number from which you want to send'; | |
| $message = sprintf( | |
| "A new lead with an ID: %s has been assigned to you.\nBest Regards.\nHazrat Bilal", | |
| $lead_id | |
| ); | |
| $response = wp_remote_post( | |
| 'https://api.httpsms.com/v1/messages/send', | |
| array( | |
| 'timeout' => 30, | |
| 'headers' => array( | |
| 'x-api-key' => $httpsms_api_key, | |
| 'Content-Type' => 'application/json', | |
| 'Accept' => 'application/json', | |
| ), | |
| 'body' => wp_json_encode( | |
| array( | |
| 'from' => $httpsms_from_number, | |
| 'to' => $phone_no, | |
| 'content' => $message, | |
| ) | |
| ), | |
| ) | |
| ); | |
| }, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment