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.

User Meta info

  1. I have a form where user can list their children and their age in a 2 column list.

    Name | Age

    I use the list un advance fields.

    Now once these are entered in to a User Meta Field called our_children.

    When I try to retrieve the data I see something like this:
    a:1:{i:0;a:2:{s:4:"Name";s:6:"Elisha";s:3:"Age";s:2:"13";}}

    I call the field using:
    $our_children = get_user_meta ($user_id,"our_children");

    How can I display this value so that I can get the name and age of children again.

    I have tried:

    foreach ( $our_children as $children ) {
    echo '<tr><td>'. $our_children -> Name .'</td><td>'. $children -> Age .'</td></tr>';
    	    }

    but it doesn't show anything.

    Thanks for your help.

    Posted 11 years ago on Monday May 27, 2013 | Permalink
  2. David Peralty

    What you have is a serialized array, and you'll have to unserialize it before you can use it properly. Have a look at the following PHP.net information page - http://php.net/manual/en/function.unserialize.php

    Posted 11 years ago on Monday May 27, 2013 | Permalink
  3. Thanks that really helped.

    Posted 11 years ago on Monday May 27, 2013 | Permalink
  4. Another trouble I am encountering is:
    Do you know how I can split this?

    the entry in the user meta is

    [who_i_am] => Array ( [0] => I home educate my children or someone else’s (registered or enrolled),I run a business that benefits home education families and I would like to list it in the Member Directory and Service Guide )

    tried this but it is not working

    $i_am = explode(",", $who_i_am);
    		     	?>
    		     	   	<li><?php echo $i_am; ?></li>
    		     	<?php

    I would like the output to be separate lines.

    Posted 11 years ago on Tuesday May 28, 2013 | Permalink
  5. David Peralty

    I am no expert PHP programmer, but shouldn't it be:

    $i_am = explode(",", $who_i_am[0]);
    Posted 11 years ago on Tuesday May 28, 2013 | Permalink
  6. I tired that

    $i_am = explode(",", $who_i_am[0]);
    		     	echo'	<li>'. $i_am .'></li>';

    This is how I am getting the user meta

    $who_i_am = get_user_meta ($user_id,"who_i_am");

    All I get is an output that says "Array".

    Posted 11 years ago on Tuesday May 28, 2013 | Permalink