• I am trying to post to a custon post type and map the form fields to the pods fields I created. It is currently working fine if I only use text fields:

    So if the form field is configured like this:

    [text high_school_education default:user_high_school_education]
    [text vocational_training default:user_vocational_training]

    Then the field appears in the mapping section correctly, and I can map the field. The problem is that the default value that is obtained from a textarea, so when the form saves it to the post field, all page breaks are lost.

    When I change the form field to:

    [textarea x8 high_school_education default:user_high_school_education]
    [textarea x8 vocational_training default:user_vocational_training]

    Then instead of showing up in the mapping section, there is only one field called “x8 (textarea)” for all of my textarea fields.

    I’ve tried then to use hooks, but I don’t think I’m doing it correctly as I’m quite new to PHP.

    I’ve copied the helper code, but not quite sure how to modify it. Do I need to return $form_data instead of $value.

    add_filter('cf7_2_post_filter-application-high_school_education','filter_application_high_school_education',10,3);
    function filter_application_high_school_education($value, $post_id, $form_data){
      //$value is the post field value to return, by default it is empty. If you are filtering a taxonomy you can return either slug/id/array.  in case of ids make sure to cast them as integers.(see https://codex.wordpress.org/Function_Reference/wp_set_object_terms for more information.)
      //$post_id is the ID of the post to which the form values are being mapped to
      // $form_data is the submitted form data as an array of field-name=>value pairs
        $form_data = $form_data['application_high_school_education']
        
        return $form_data;
    }

    Your help would be sooo much appreciated!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter michael9689

    (@michael9689)

    Okay, so I’ve figured out why there was only “x8 (textarea)” form fields in the mapping section. So it looks like I don’t need to use hooks? I’ve changed the form fields to the following:

    [textarea x8high_school_education default:user_high_school_education]
    [textarea x8vocational_training default:user_vocational_training]

    So now all the fields are showing up in the mapping section

    See https://prnt.sc/XBFFcrX3jb-o

    But now when I submit the form, none of the fields (even the normal text fields) are being mapped. It is not even naming the post correctly. With only text fields mapped (no textarea fields), the post was named correctly and the data was mapped correctly.

    See https://prnt.sc/L86_hxc8SepQ

    Please help!

    • This reply was modified 2 years, 1 month ago by michael9689.
    Plugin Author Aurovrata Venet

    (@aurovrata)

    [textarea x8 vocational_training default:user_vocational_training]

    Is wrongly formatted.

    It should be

    [textarea vocational_training default:user_vocational_training x8]

    The x8 needs to come at the end! This is important

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can’t Map custom field to form textarea field’ is closed to new replies.