This is working better. However I would like to send a link to the top of the thread rather than to the last link. I am not understanding how that happens in class-fep-emails.php. I have tried using fep_query_url( ‘messagebox’ ) but it is not sufficient. Is there a function that I can use to make the url for $message_id point to the top of the thread?
add_action( ‘fep_action_message_after_send’, ‘send_sms_with_twilio’, 100, 3 );
function send_sms_with_twilio( $message_id, $message, $inserted_message ){
$participants = fep_get_participants( $message_id );
foreach ( $participants as $participant ) {
$email = fep_get_userdata( $participant, ‘user_email’, ‘id’ );
$user = get_user_by( ’email’, $email );
$userId = $user->ID;
$phone = get_the_author_meta( ‘phone_number’, $userId );
$gateway = get_the_author_meta( ‘cell_carrier’, $userId );
$smsgateway= $phone.$gateway;
if( preg_match(“/_|@|%/”, $smsgateway) )
{
$to = $smsgateway; //the phonenumber@sms.provider
$subject = ‘New Message at TuckerWorks go to’; //No subject line
$body = site_url( ‘/client-portal/’, ‘https’ ) . ‘?fepaction=viewmessage&fep_id=’ . $message_id;
$headers = array(‘Content-Type: text/plain; charset=UTF-8’);
wp_mail( $to, $subject, $body, $headers );
}
}
}