php - Get user by meta data key and velue
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";}
)
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";}
)
Share
Improve this question
edited Mar 21, 2019 at 12:17
Qaisar Feroz
2,1471 gold badge9 silver badges20 bronze badges
asked Mar 21, 2019 at 11:52
NewBleNewBle
12 bronze badges
5
|
1 Answer
Reset to default 0This how my stored data function is for this meta group and get data
stored
$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
最新文章
- 谷歌强推安卓8.0系统:明年所有APP都必须支持
- 死忠安卓粉看iPhone 6S:根本没创新!
- 3Q大战2012版打起来了
- reactjs - The difference between @Vite4 and @Vite5 - Stack Overflow
- anaconda - Trouble using fiona in conda environment: ImportError: DLL load failed while importing _env - Stack Overflow
- php - Yii2 ActiveForm Model doesn't exist - Stack Overflow
- express - How can I access a cookie (refreshToken) on the server side in Next.js? - Stack Overflow
- python - Converting Document Docx with Comments to markit using markitdown - Stack Overflow
- malloc - C memory leak warning - Stack Overflow
- macos - Restriction of media fetched with API in browser in iOS and Mac systems - Stack Overflow
- Angular post request body is null when received by Spring API - Stack Overflow
- c - Validity of `__attribute__((pure))` - Stack Overflow
- html - django multi-level template extending - Stack Overflow
- Need to find a way to change a library (SO file) without reinstalling an application in Android 13 on rooted device. Permission
- javascript - Save andor Apply Background Image on click - Stack Overflow
- Page Performance Issue with Countdown in Angular on Component Reload - Stack Overflow
- reactjs - How to render text and list from markdown frontmatter on Next project? - Stack Overflow
maybe_unserialize()
for help getting that data into a readable format – mrben522 Commented Mar 21, 2019 at 14:44