Levi Dulstein has a lot of righ, but in my opinion Front-end-pm uses two hooks to send messages:
- fep_save_message (from back-end)
- fep_action_message_after_send (from front-end)
Before sending a email few things are checked, like publishig or sending status (includes/class-fep-emails.php):
function save_send_email( $postid, $post ) {
if ( ! $post instanceof WP_Post ) {
$post = get_post( $postid );
}
if ( 'publish' != $post->post_status ){
return;
}
if ( get_post_meta( $postid, '_fep_email_sent', true ) ){
return;
}
$this->send_email( $postid, $post );
}
So, for test try add something like this to your plugin or theme:
function send_sms( $postid, $post ) {
if ( ! $post instanceof WP_Post ) {
$post = get_post( $postid );
}
if ( 'publish' != $post->post_status ){
return;
}
if ( get_post_meta( $postid, '_fep_email_sent', true ) ){
return;
}
// use Twilio plugin function twl_send_sms
if( function_exists('twl_send_sms') ) {
$participants = fep_get_participants( $postid );
// check if recipients exists, for each get the phone number,
// send message and mark sms as sent (or save sms send time)
$args = array(
'message' => $post->post_title, // or $post->post_content
);
foreach ($participants as $participant) {
// get usermeta with phone number for $participant ID
$args['number_to'] = '098765';
twl_send_sms( $args );
}
}
}
add_action( 'fep_save_message', 'send_sms', 99, 2 ); //sending from back-end
add_action( 'fep_action_message_after_send , 'send_sms', 99, 2 ); //front-end
Sorry for my english. I hope you understand what I want to say.