Support » Plugin: Form to Post » Dynamic Value Not posted

  • Resolved moni

    (@muneeba)


    Hi, First of all thank you for this plugin.
    I am generating a hidden field in contact form with this code [hidden Myid] and posting it in CFDB with the combination of different from fields with this code:

    function add_new_id($formData) {
    $formData->posted_data['Myid'] = $formData->posted_data['Name'].$formData->posted_data['Age'].$formData->posted_data['DOB'];
    return $formData;
    }
    add_filter('cfdb_form_data', 'add_new_id');
    

    The Field is successfully generated like this : Amenda211998-02-01
    These values also show in CFDB datatable
    But when I try to post this dynamic value with form to post all the contact form fields posted except ( Myid ) my form to post Code is:

     // Next line sets the post_title value 
    $form_data->posted_data['post_title'] = "My ID is {$form_data->posted_data['Myid']}";
    

    I also tried to load this dynamic key with this code but it doesn’t help

    // Next line sets the post_title value
    		// Next line sets the post_content value
    $Myid = implode('_ , _' $form_data->posted_data['Myid']);
            $form_data->posted_data['post_title'] = "My ID is {$form_data->posted_data['$Myid']}";

    Please suggest me solution I am not good at PHP.

    • This topic was modified 3 years, 6 months ago by moni. Reason: some argument missing in writing code first
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    The CFDB function that you added only makes the new Myid field for CFDB in its own local copy of the form submission. That change is not seen by any other plugin. Ignore the CFDB example and follow a Form To Post example like the following.

    function f2p_add_new_id( $form_data ) {
        $form_title = 'YOUR FORM NAME'; // Change this to your form name
        if ($form_data->title = $form_title) {
            $form_data->posted_data['post_title'] = "My ID is {$form_data->posted_data['Myid']}";
        }
        return $form_data;
    }
    add_filter( 'form_to_post_form_data', 'f2p_add_new_id', 10, 1 ); 
    

    Yes exactly my form to post function is same like this example in short code actions and filters plugin.
    But when I submit form ( My ID is ) this title is posted only but ID does not posted.
    {$form_data->posted_data[‘Myid’]} this dynamic ID does not posted with text.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic Value Not posted’ is closed to new replies.