MP_Addon_SMS_Callback::json_send_sms()

Send manually sms to lead from the lead page.

Contents


Source Source

File: calculator-sms-add-on/inc/MP_Addon_SMS_Callback.php

	public function json_send_sms() {

		MP_Callback::check_nonce( $_POST['nonce'], 'mortgage_json-request' );

		$post_id = $_POST['leadId'];
		$number  = '+' . $_POST['leadPhone'];
		$body    = $_POST['leadSMSText'];

		$smssend = $this->send( $number, $body );

		$smssend_status = '' === $smssend->errorMessage ? 'Success' : $smssend->errorMessage;
		MP_Logs::set_logs( $post_id, 'lead_sms_manually', $smssend_status . ': SID: ' . $smssend->sid );

		$message = array(
			'date' => current_time( 'Y-m-d H:i:s' ),
			'body' => $body,
			'from' => 'admin',
		);

		add_metadata( 'post', $post_id, MortgagePlatform::$prefix . 'sms', wp_slash( $message ), '' );

		$response['status']  = $smssend_status;
		$response['message'] = $message;

		wp_send_json( $response );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.