Home › Forums › Front End PM PRO › Muliple recipients in fep_shortcode_new_message_form shortcode
- This topic has 6 replies, 2 voices, and was last updated 7 years, 11 months ago by Shamim Hasan.
- AuthorPosts
- January 18, 2018 at 7:52 pm #10008Alex BrearleyParticipant
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
January 18, 2018 at 10:52 pm #10013Alex BrearleyParticipantIf 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?
January 18, 2018 at 11:24 pm #10016Shamim HasanKeymasterThis 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 usefep_filter_message_before_sendand passmessage_to_idas array of user ids. remember it already holds current recipient (may be as string), so add only other users.January 19, 2018 at 12:26 pm #10022Alex BrearleyParticipantSo 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?
January 19, 2018 at 6:02 pm #10031Shamim HasanKeymasterYou 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; });January 20, 2018 at 11:13 pm #10051Alex BrearleyParticipantThank 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.
January 21, 2018 at 9:38 am #10069Shamim HasanKeymasterYou can return empty array, that will short circuit the function and halt/abort creation of message.
- AuthorPosts
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.