I have create custom user meta, but it was array how i can call only one of them by key like I want to get only course_id = 22 list.
Here this my user meta array

 [certifications] => Array
            [0] => a:9:{s:9:"course_id";a:2:{i:0;s:0:"";i:1;s:2:"19";}s:11:"course_name";a:2:{i:0;s:0:"";i:1;s:18:"Advanced Freediver";}s:6:"course";a:2:{i:0;s:0:"";i:1;s:2:"19";}s:4:"date";a:2:{i:0;s:0:"";i:1;s:10:"05/03/2019";}s:10:"instructor";a:2:{i:0;s:0:"";i:1;s:11:"Camila Amor";}s:6:"school";a:2:{i:0;s:0:"";i:1;s:24:"Apnea Total Headquarters";}s:11:"pdf_card_id";a:2:{i:0;s:0:"";i:1;s:2:"19";}s:7:"pdf_dip";a:2:{i:0;s:0:"";i:1;s:2:"19";}s:11:"last_update";s:10:"21-03-2019";}
            [1] => a:9:{s:9:"course_id";a:2:{i:0;s:0:"";i:1;s:2:"22";}s:11:"course_name";a:2:{i:0;s:0:"";i:1;s:16:"Master Freediver";}s:6:"course";a:2:{i:0;s:0:"";i:1;s:2:"22";}s:4:"date";a:2:{i:0;s:0:"";i:1;s:10:"08/03/2019";}s:10:"instructor";a:2:{i:0;s:0:"";i:1;s:14:"Andres Alegria";}s:6:"school";a:2:{i:0;s:0:"";i:1;s:17:"Vertical Dreamers";}s:11:"pdf_card_id";a:2:{i:0;s:0:"";i:1;s:2:"22";}s:7:"pdf_dip";a:2:{i:0;s:0:"";i:1;s:2:"22";}s:11:"last_update";s:10:"21-03-2019";}
  • how are you creating this meta? and why is it being stored as serialized data inside an array?
    – mrben522
    Mar 21, 2019 at 12:57
  • it is default array stored from wordpress.
    – NewBle
    Mar 21, 2019 at 13:53
  • please add the code you are using to create/store that meta and what you are using to pull it out in the current format
    – mrben522
    Mar 21, 2019 at 14:15
  • This how my stored function is for this meta group $certification = array( 'course_name' => $certificate_name, 'course' => $certificate, 'date' => $date, 'instructor' => $certifying_instructor, 'school' => $school, 'last_update' => date('d-m-Y'), ); add_user_meta( $user_ids, 'certifications', $certification );
    – NewBle
    Mar 21, 2019 at 14:34
  • If you have to have them all stored in a single meta field ('certifications') then you're going to need to parse out the data in them and then pullout the array you want from there. check out maybe_unserialize() for help getting that data into a readable format
    – mrben522
    Mar 21, 2019 at 14:44

1 Answer 1


This how my stored data function is for this meta group and get data


$certification = array(
        'course_id' => $certificate_id,
        'course' => $certificate,
        'date' => $date,
        'instructor' => $certifying_instructor,
        'school' => $school,
        'last_update' => date('d-m-Y'),

    add_user_meta( $user_ids, 'certifications',  $certification );

and this get data

$users_detail = get_user_meta($user_id);
$certificates = $users_detail['certifications'];

$n_course_id = array();

foreach ($certificates as $value) {
   $course = unserialize($value);
   $course_id = $course['course_id'];

   foreach ($course_id as $courses) {
     array_push($n_course_id, $courses);


by this function i can get all list but i want to get only one of them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.