Add fields to form?


Home Forums Front End PM PRO Add fields to form?

This topic is: Resolved
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #42307
    tonlogicdevworks
    Participant

    Hello! How do we add fields to this form? We need a Quote #, Job reference # fields.

    Thanks!

    https://www.shamimsplugins.com/docs/front-end-pm/shortcode/fep_shortcode_new_message_form/

    #42316
    Shamim Hasan
    Keymaster

    You can follow https://www.shamimsplugins.com/support/topic/additional-message-field/#post-20346 (there checkbox is added, you can add any type of fields) change newmessage to shortcode-newmessage

    #42335
    tonlogicdevworks
    Participant

    we have tried this but it is not working on the front end shortcode form…

    add_filter( ‘fep_form_fields’, function( $fields ){
    $fields[‘cus_fep_textbox1’] = [
    ‘type’ => ‘text’,
    ‘where’ => ‘shortcode-newmessage’,
    ‘priority’ => 22,
    ‘cb_label’ => ‘Quote #’,
    ];
    return $fields;
    });

    #42337
    tonlogicdevworks
    Participant

    ok we resolved the fields on the frontend form but the added fields do not appear in the message when sent.

    add_filter( ‘fep_form_fields’, function( $fields ){
    $fields[‘cus_fep_textbox1’] = [
    ‘type’ => ‘text’,
    ‘where’ => ‘shortcode-newmessage’,
    ‘priority’ => 12,
    ‘label’ => ‘Quote Number’,
    ];
    return $fields;
    });
    add_filter( ‘fep_form_fields’, function( $fields ){
    $fields[‘cus_fep_textbox2’] = [
    ‘type’ => ‘text’,
    ‘where’ => ‘shortcode-newmessage’,
    ‘priority’ => 13,
    ‘label’ => ‘Job Reference Number’,
    ];
    return $fields;
    });

    #42375
    Shamim Hasan
    Keymaster

    You will need to save and display that value as well. Please see that link. There are more 2 blocks of code there you need to add.

    #42381
    tonlogicdevworks
    Participant

    Still stumped.
    The field label “Quote Number” is not showing or coming through in a message…

    add_filter( ‘fep_form_fields’, function( $fields ){
    $fields[‘cus_fep_textbox1’] = [
    ‘type’ => ‘text’,
    ‘where’ => ‘shortcode-newmessage’,
    ‘priority’ => 12,
    ‘cb_label’ => ‘Quote Number?’,
    ];
    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_checkbox’, $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 ‘Quote Number’;
    }
    });

    #42383
    tonlogicdevworks
    Participant

    We have made progress! But how do we separate the fields in the message box? Meaning we would like each field to get its own line

    https://prnt.sc/xq6mzt

    add_filter( 'fep_form_fields', function( $fields ){
    	$fields['cus_fep_textbox1'] = [
    		'type'     => 'text',
    		'where'    => 'shortcode-newmessage',
    		'priority' => 12,
    		'label' => 'Quote Number',
    	];
    	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 ( $cus_fep_textbox1 = fep_get_meta( fep_get_the_id(), 'cus_fep_textbox1', true ) ) {
    		echo 'Quote Number:      '; echo esc_html( $cus_fep_textbox1 );
    	}
    });
    
    add_filter( 'fep_form_fields', function( $fields ){
    	$fields['cus_fep_textbox2'] = [
    		'type'     => 'text',
    		'where'    => 'shortcode-newmessage',
    		'priority' => 13,
    		'label' => 'Job Reference #',
    	];
    	return $fields;
    });
    
    add_action( 'fep_action_message_after_send', function( $message_id, $message, $new_message ){
    	if ( ! empty( $message['cus_fep_textbox2'] ) ) {
    		fep_add_meta( $message_id, 'cus_fep_textbox2', $message['cus_fep_textbox2'], true );
    	}
    }, 10, 3);
    
    add_action( 'fep_display_after_message', function(){
    	if ( $cus_fep_textbox2 = fep_get_meta( fep_get_the_id(), 'cus_fep_textbox2', true ) ) {
    		echo 'Job Reference #:      '; echo esc_html( $cus_fep_textbox2 );
    	}
    });
    
    #42396
    Shamim Hasan
    Keymaster

    Please use like

    echo '<div>Quote Number: ' . esc_html( $cus_fep_textbox1 ) . '</div>';
    
    #42402
    tonlogicdevworks
    Participant

    Awesome! Thanks!

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.