Join our new community forum for support & discussion

Join Now

Home Support Extensions Messages How to get the messages tokens within the forms message_send?

How to get the messages tokens within the forms message_send?

  • Author
    Posts
  • dreamermates

    Hi Ihor/team!
    We’re trying to retrieve the data from the messages section to send customized emails via mailchimp/mandrill without using the HivePress email feature / wp_mail.
    Basically, this is already working when we’re integrating our trigger into
    add_action ('hivepress/v1/forms/message_send', function ($form) {

    Open question:
    How can we retrieve the relevant data from class-message or class-message-send ?
    With e. g.
    hivepress()->translator->get_string( 'send_message' );
    we’re getting the label of the button, ok, but how to get the relevant data for the textarea
    or the tokens (%user_name%, %message_url%, %message_text%, %message%, %sender%, %reciepient%) ?

    Many thanks in advance!
    Flo & team

    ihor developer

    Please try this code snippet instead:

    add_filter(
    	'hivepress/v1/emails/message_send',
    	function( $email ) {
    		$email['body'] = '';
    
    		return $email;
    	},
    	1000
    );

    It prevents the default email from being sent, and you can send your custom email instead, the $email array contains all the tokens and the email text.

    dreamermates

    Thanks so far, to replace the email with our custom email is working, yes.
    But how can we retrieve the content of the message that was sent by the user?
    Background: We wanna share this in our email as a preview.
    Thanks in advance!
    Flo & team

    ihor developer

    If you use the above filter you can get the message text from the $email[‘tokens] array, if you added or changed the email text in HivePress/Emails then you can simply use this token:

    %message_text%

    And it’ll be replaced with the message text.

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

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.