• Resolved Degas

    (@degas)


    Hi, thanks for this plugin. We have a couple of issues with our form, wondering if these can be addressed within CF7 or need addressing elsewhere.

    1. Looking to import a string variable into a database meta field that expects the format a:1:{i:0;s:8:”12345678″;} where 12345678 is the variable.
      Including the variable in a string to match the above adds s25 and quotes when the data is inserted into the database, ie s:25:”a:1:{i:0;s:8:”63028828″;}”; which is then unrecognised by the page requiring this data.
      Applying json encode to the data gives us “a:1:{i:0;s:8:”12345678″;}”, again the quotes prevent the data from being read.
      How might we pull through our core string as intended without it being wrapped?
    2. We’d like the Select option values to pull through differently from their labels, ie a ’20 images’ label pulls through 20 as the value. Inital tests using pipes haven’t worked, is there anywhere within Post My CF7 Form that addresses this?

    Thanks for any help, excuse me if I’ve missed anything obvious.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Degas

    (@degas)

    Quick FYI, have solved Q2 with the solution from https://www.ads-software.com/support/topic/select-with-pipes/.

    Currently still stuck on Q1, any help much appreciated.

    Thread Starter Degas

    (@degas)

    Finally solved Q1 (and learnt about serialized data). My solution was to add an action (as per 3.6 in Hooks & Filters to customise the mapping) with a function to unserialize the submitted data as all forms of data manipulation tried had simply resulted in unchanged or reserialized data

    add_action(‘cf7_2_post_form_submitted_to_clientspage’, ‘new_clientspage_mapped’,1000, 4); // changed priority from 10 to 1000
    /**

    * Function to take further action once form has been submitted and saved as a post. Note this action is only fired for submission which has been submitted as opposed to saved as drafts.
    * @param string $post_id new post ID to which submission was saved.
    * @param array $cf7_form_data complete set of data submitted in the form as an array of field-name=>value pairs.
    * @param string $cf7form_key unique key to identify your form.
    * @param array $submitted_files array of files submitted in the form, if any file fields are present.
    */

    function new_clientspage_mapped($post_id, $cf7_form_data, $cf7form_key, $submitted_files){
    //do something. $user_array = get_post_meta($post_id,’user_ids’, true);
    $user_array = unserialize( $user_array ); update_post_meta($post_id,’user_ids’,$user_array);
    }

    Hope this helps someone ??

    Plugin Author Aurovrata Venet

    (@aurovrata)

    well done, glad you figured it out. Please use <code> markup for your code example so that it is more legible.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    thanks for this plugin

    wc, please leave a review when you have a moment to spare.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Format to insert data’ is closed to new replies.