PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Please help me unserialize this:

  1. So I understand that this returns a value from the usermeta table:

    add_filter('gform_field_value_user_firstname', create_function("", '$value = populate_usermeta(\'first_name\'); return $value;' ));

    How do I do it if the field in the table is serialized?

    I want to prepopulate a gravityform field that I have given the parameter "phone" It is serialized in a field called mp_billing_info as 'phone'

    Here's the data that is in that field:
    a:9:{s:5:"email";s:0:"";s:4:"name";s:17:"Billing Full Name";s:8:"address1";s:11:"Billing One";s:8:"address2";s:12:"Billing Two ";s:4:"city";s:12:"Billing City";s:5:"state";s:2:"GA";s:3:"zip";s:5:"30360";s:7:"country";s:2:"US";s:5:"phone";s:10:"7705555555";}

    Help!

    Posted 13 years ago on Wednesday November 16, 2011 | Permalink
  2. How about the WordPress function maybe_unserialize? That's based on the PHP unserialize function.

    http://codex.wordpress.org/Function_Reference/maybe_unserialize

    Sometimes the work has been done for you in WordPress though. Maybe there is another function to extract the information you need without operating on the data directly.

    Posted 13 years ago on Wednesday November 16, 2011 | Permalink
  3. I'm an idiot. Any chance of showing me what I would need to put into the functions.php to make this work? pretty please.

    Posted 13 years ago on Wednesday November 16, 2011 | Permalink
  4. Hi Andy,

    Try this:

    http://pastie.org/2874887

    The get_serialized_usermeta function will require two parameters; the parent meta key and the child meta key. In your case, the parent meta key would be "mp_biling_info" and the child meta key would be "phone". If you wanted to get another piece of user meta from the "mp_billing_info", you would just pass whatever child meta key you want to retrieve.

    Posted 13 years ago on Wednesday November 16, 2011 | Permalink