Muliple recipients in fep_shortcode_new_message_form shortcode


Home Forums Front End PM PRO Muliple recipients in fep_shortcode_new_message_form shortcode

This topic is: Not Resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10008
    Alex Brearley
    Participant

    Hi Shamim,

    I would like to use the fep_shortcode_new_message_form shortcode to create a message form that will send a message to multiple recipients. I tried a comma separated list of wordpress usernames in the to field but that did not work. Is this possible?

    [fep_shortcode_new_message_form to=”username1,username2″ subject=”Test Subject”]

    Thanks

    #10013
    Alex Brearley
    Participant

    If the shortcode does not support multiple users in to, would it be possible to add the users using the fep_action_message_after_send hook i.e. insert post_meta data to add that particular message ID to other users inbox?

    #10016
    Shamim Hasan
    Keymaster

    This shortcode does not support multiple recipient.
    You can use fep_action_message_after_send hook to set participants to other user but may encounter some caching issue with message count. Instead You can use fep_filter_message_before_send and pass message_to_id as array of user ids. remember it already holds current recipient (may be as string), so add only other users.

    #10022
    Alex Brearley
    Participant

    So basically, change $message_to_id to an array of user ids. Do I need to return $message_to_id from the function or is it just enough to change it? Are there 3 parameters on _before_send like there are on after_send?

    I presume that once multiple participants have been added, any future replies will go to everyone i.e. if I send the first message to two people, if one of those 2 people respond, I receive it and the other person from the 2 receive it? Or, is it the case that the _before_send hook has to everytime a reply is sent, work out the to list?

    #10031
    Shamim Hasan
    Keymaster

    You can add following code in your theme’s (child theme’s if any) functions.php

    add_filter('fep_filter_message_before_send', function( $message ){
        $your_extra_user_ids = array( 1,2,3 );
    
        //Only for parent message
        if( empty($message['post_parent'] ) ){
            if( ! is_array( $message['message_to_id'] ) ){
                $message['message_to_id'] = array( $message['message_to_id'] );
            }
            $message['message_to_id'] = array_merge( $message['message_to_id'], $your_extra_user_ids );
        }
        return $message;
    });
    
    #10051
    Alex Brearley
    Participant

    Thank you – I will give this code snippet a go.

    Out of interest, is it possible to use the fep_filter_message_before_send filter to also halt/abort creation of the message by manipulating the variables within its scope? I am wondering if I could within this filter check that something related to my app is correct and if not abort creation of the message.

    #10069
    Shamim Hasan
    Keymaster

    You can return empty array, that will short circuit the function and halt/abort creation of message.

Viewing 7 posts - 1 through 7 (of 7 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.