Home › Forums › Front End PM PRO › show and reply to specific message ID
- This topic has 12 replies, 2 voices, and was last updated 6 years, 11 months ago by Alex Brearley.
-
AuthorPosts
-
December 5, 2017 at 4:19 pm #8327Alex BrearleyParticipant
Is there an action to capture the message ID for a new message thread when created and then use that ID to show (by placement of a shortcode) that particular thread to a user? The idea is that the user could have mutliple support cases open and I would like them to be able to click on each support case and view the messages just for that case rather than using the dashboard to view all current messages covering all support cases.
Kind Regards,
Alex
December 6, 2017 at 10:18 pm #8361Shamim HasanKeymasterwhen message is sent
fep_action_message_after_send
is fired. first argument is message id of newly created message.If you want to show only one message then you have to custom code for that. You can use
fep_get_message_with_replies()
function to retrieve any message and show them anywhere.January 3, 2018 at 10:27 pm #9579Alex BrearleyParticipantThanks Shamin for your response. How many arguments are sent from the fep_action_message_after_send action? To use fep_get_message_with_replies function, what global do I need define or what file do I need to include?
January 4, 2018 at 11:37 am #9582Shamim HasanKeymasterthree arguments are sent from fep_action_message_after_send action.
You can use fep_get_message_with_replies( $id ) to get message with replies of given id.
Please see functions.php of this plugin to see code.January 8, 2018 at 8:22 pm #9677Alex BrearleyParticipantIs it possible to prevent the user from changing the subject when using the fep_shortcode_new_message_form shortcode? I need to associate an ID (from my web app) with the message/post ID generated by fep. At the moment the only way I can see of doing this is to embed the ID into the subject of the fep message but then there is the risk that the user changes it. Using CSS to hide it is not robust as someone could unhide it from their browser if they so wished.
Ideally I would like to pass my ID to fep so that when it creates the first message, it stores my ID as a post_meta data. Is that possible?
Thanks
January 8, 2018 at 10:06 pm #9680Shamim HasanKeymasterWhen you are getting your ID (from web app)? If you can capture your ID when message sent you can add like bellow code
add_action( 'fep_action_message_after_send', function( $message_id, $message, $inserted_message ){ add_post_meta( $message_id, '_your_custom_meta_key', $id_from_web_app ); }, 10, 3 );
January 9, 2018 at 4:24 pm #9706Alex BrearleyParticipantThe ID is actually a parameter in the URL on the page that has the fep_shortcode_new_message_form shortcode on. I’m currently investigating how to provide that parameter to the fep_action_message_after_send action.
January 9, 2018 at 4:42 pm #9709Shamim HasanKeymasterYou can use
$_SERVER['HTTP_REFERER']
to capture id or create a hidden field to provide that id. If you need more secure way you can create 2 hidden field, one for id and another for token created for that id. So that if anybody change that id, that will mismatch token so that you can reject that.January 9, 2018 at 4:51 pm #9712Alex BrearleyParticipantIf you have any guidance on how I can pass the ID in the parameter to the action hook that would be appreciated.
January 9, 2018 at 4:52 pm #9715Alex BrearleyParticipantsorry, our messages overlapped – thanks for your help I will give that a go
January 9, 2018 at 5:10 pm #9718Alex BrearleyParticipantAs a suggestion, would you be open to updating the shortcode to accept post_meta values?
For example:
fep_shortcode_new_message_form to=”{current-post-author}” subject=”{current-post-title}” post_meta=”id,12345678″]
January 9, 2018 at 6:48 pm #9721Shamim HasanKeymasterThat will not be practical because every field require individual type of validation and sanitize.
You can easily capture id from url and add that in post meta. Use code like
add_action( 'fep_action_message_after_send', function( $message_id, $message, $inserted_message ){ wp_parse_str( $_SERVER['HTTP_REFERER'], $referrer ); $id = !empty( $referrer['id'] ) ? absint($referrer['id']) : 0; //Change id with your parameter //here if require check some validation add_post_meta( $message_id, '_your_custom_meta_key', $id ); }, 10, 3 );
January 9, 2018 at 7:28 pm #9725Alex BrearleyParticipantThank you ever so much for your help 🙂
-
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.