show and reply to specific message ID


Home Forums Front End PM PRO show and reply to specific message ID

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

    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

    #8361
    Shamim Hasan
    Keymaster

    when 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.

    #9579
    Alex Brearley
    Participant

    Thanks 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?

    #9582
    Shamim Hasan
    Keymaster

    three 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.

    #9677
    Alex Brearley
    Participant

    Is 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

    #9680
    Shamim Hasan
    Keymaster

    When 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 );
    
    #9706
    Alex Brearley
    Participant

    The 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.

    #9709
    Shamim Hasan
    Keymaster

    You 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.

    #9712
    Alex Brearley
    Participant

    If you have any guidance on how I can pass the ID in the parameter to the action hook that would be appreciated.

    #9715
    Alex Brearley
    Participant

    sorry, our messages overlapped – thanks for your help I will give that a go

    #9718
    Alex Brearley
    Participant

    As 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″]

    #9721
    Shamim Hasan
    Keymaster

    That 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 );
    
    #9725
    Alex Brearley
    Participant

    Thank you ever so much for your help 🙂

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