Additional Message Field


Home Forums Front End PM PRO Additional Message Field

This topic is: Resolved

Tagged: ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #20308
    foamshore
    Participant

    Firstly thank you for a wonderful plugin. It is perfect.

    One thing would make my day/year so much happier…

    Is it possible to add another field to a message?

    Ideally, I’d like to add a checkbox to the compose area saying “Can we use this for marketing”

    If the checkbox is marked, the admin will be able to see / recipient will be able to see (whatever is easier) thank you so much

    #20320
    shamim
    Keymaster

    You can use fep_form_fields filter hook to add any additional fields and fep_display_after_message hook to show that bellow message.

    #20334
    foamshore
    Participant

    Thank you 🙂 I have found this code and modified to add a checkbox, which it seems to do.

    add_filter( ‘fep_form_fields’, function( $fields ){
    $fields[‘public’] = [
    ‘type’ => ‘checkbox’,
    ‘label’ => ‘Can we use your message on the site as a story?’,
    ‘where’ => ‘newmessage’,
    ‘priority’ => 22,
    ‘function’ => function( $field ){
    },
    ];
    return $fields;
    });

    I am lost on how to display the field using the display after the message hook, ive tried echoing the value out by editing the message template which I know is bad, but im not sure what the value is?

    <?php echo $public;?>
    <?php echo fep_form_fields( ‘public’ ); ?>
    <?php echo $field; ?>
    <?php echo $fields; ?>

    Sorry for sounding completely stupid! Any pointers would be great 🙂 thank you so much

    #20346
    shamim
    Keymaster

    Add following code in your theme’s (child theme’s if you are using) functions.php

    add_filter( 'fep_form_fields', function( $fields ){
    	$fields['cus_fep_checkbox'] = [
    		'type'     => 'checkbox',
    		'where'    => 'newmessage',
    		'priority' => 22,
    		'cb_label' => 'Can we use your message on the site as a story?',
    	];
    	return $fields;
    });
    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $new_message ){
    	if ( ! empty( $message['cus_fep_checkbox'] ) ) {
    		fep_add_meta( $message_id, 'cus_fep_checkbox', $message['cus_fep_checkbox'], true );
    	}
    }, 10, 3);
    
    add_action( 'fep_display_after_message', function(){
    	if ( fep_get_meta( fep_get_the_id(), 'cus_fep_checkbox', true ) ) {
    		echo 'We can use this message on the site as a story';
    	}
    });
    
    #20489
    David
    Participant

    Hi,

    I’d like to achieve a similar thing but using 1-3 separate text boxes that would sit above the message box on the view message page. Any help with this would be much appreciated. I have tried the above but changing the ‘fep_action_message_after_send’ to ‘fep_display_before_messagebox’ but it is not working.

    #20493
    David
    Participant

    Ok, have got to this stage which has added a text box but not sure how to echo the info from the text box into the message? Is it possible to replace the word ‘hello’ below with the details entered into textbox1?

    add_filter( 'fep_form_fields', function( $fields ){
    	$fields['cus_fep_textbox1'] = [
    		'type'     => 'text',
    		'where'    => 'reply',
    		'priority' => 22,
    		'label' => 'Start Point',
    	];
    	return $fields;
    });
    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $new_message ){
    	if ( ! empty( $message['cus_fep_textbox1'] ) ) {
    		fep_add_meta( $message_id, 'cus_fep_textbox1', $message['cus_fep_textbox1'], true );
    	}
    }, 10, 3);
    
    add_action( 'fep_display_after_message', function(){
    	if ( fep_get_meta( fep_get_the_id(), 'cus_fep_textbox1', true ) ) {
    		echo hello;
    	}
    });
    
    #20499
    shamim
    Keymaster

    change your code last part with following code

    add_action( 'fep_display_after_message', function(){
    	if ( $cus_fep_textbox1 = fep_get_meta( fep_get_the_id(), 'cus_fep_textbox1', true ) ) {
    		echo esc_html( $cus_fep_textbox1 );
    	}
    });
    
    #20512
    David
    Participant

    Brilliant, thanks!!

    #20622
    David
    Participant

    Is it possible to prepopulate this additional field? I tried adding it the same as &message_title= and &message_content= but it did not work…

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