Getting Message ID in fep_filter_before_email_send


Home Forums Front End PM PRO Getting Message ID in fep_filter_before_email_send

This topic is: Not Resolved

Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #45975
    Craig Tucker
    Participant

    Hello Shamim,
    My next project is to send client text messages. I am using the fep_filter_before_email_send and sending the message through wp_mail. I would like to recreate the link to the message the following is for example. It almost works.:

    add_filter( ‘fep_filter_before_email_send’, ‘sms_send_msg’, 10, 3 );

    function sms_send_msg( $message_id)
    {
    $phone = get_the_author_meta( ‘phone_number’, $user->ID );
    $gatway = get_the_author_meta( ‘cell_carrier’, $user->ID );
    if( preg_match(“/_|@|%/”, $gatway) ) {
    $to = $phone . $gatway; //the phonenumber@sms.provider
    $subject = ”; //No subject line
    $body = ‘You have a new message at: ‘. $website = site_url( ‘/client-portal/’, ‘https’ ) ;
    $headers = array(‘Content-Type: text/html; charset=UTF-8’);
    wp_mail( $to, $subject, $body, $headers );
    }
    }

    #45976
    Craig Tucker
    Participant

    I see I am way off. I am moving to class-fep-emails.php and making mods there. That should work.

    #45977
    Craig Tucker
    Participant

    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 );
    }
    }
    }

    #45978
    Shamim Hasan
    Keymaster

    You can use fep_query_url( 'viewmessage', array( 'fep_id' => fep_get_message_field( 'mgs_parent', $message_id ) ?: $message_id ) )

Viewing 4 posts - 1 through 4 (of 4 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.