Home › Forums › Front End PM PRO › Additional Message Field
Tagged: extra field, field
- This topic has 8 replies, 3 voices, and was last updated 5 years, 10 months ago by David.
-
AuthorPosts
-
January 3, 2019 at 5:10 am #20308foamshoreParticipant
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
January 3, 2019 at 6:56 pm #20320Shamim HasanKeymasterYou can use
fep_form_fields
filter hook to add any additional fields andfep_display_after_message
hook to show that bellow message.January 3, 2019 at 9:55 pm #20334foamshoreParticipantThank 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
January 4, 2019 at 3:44 am #20346Shamim HasanKeymasterAdd 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'; } });
January 7, 2019 at 5:06 pm #20489DavidParticipantHi,
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.
January 7, 2019 at 6:50 pm #20493DavidParticipantOk, 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; } });
January 7, 2019 at 7:06 pm #20499Shamim HasanKeymasterchange 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 ); } });
January 7, 2019 at 10:15 pm #20512DavidParticipantBrilliant, thanks!!
January 10, 2019 at 8:38 pm #20622DavidParticipantIs it possible to prepopulate this additional field? I tried adding it the same as &message_title= and &message_content= but it did not work…
-
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.