如何为单个元字段中的每个子数组字段更新用户元数据

时间:2019-03-23 03:23:57

标签: php wordpress

我已经存储了用户元呼叫用户证书组,这是具有阵列的每个用户的单个元字段,每个用户可以拥有一个以上的证书,并且可以更新每个证书项目。 如何更新每个认证项目? 例如我想更新证书Array [1]字段course_name怎么办 或者,如果您有关于存储的用户元组的其他解决方案,请告知。 这是我如何保存元数据

$certification = array(
    'course_id' => $certificate,
    'course_name' => $certificate_name,
    'date' => $date,
    'instructor' => $certifying_instructor,
    'school' => $school,        
    'last_update' => date('d-m-Y'),
);
add_user_meta( $user_ids, 'certifications',  $certification );

当我执行print_r时,此结果

$certifications = get_user_meta( $user_id, 'certifications' );

echo "<pre>";
print_r($certifications );
echo "</pre>";

Array
  (
  [0] => Array
    (
        [course_id] => Array
            (
                [0] => 
                [1] => 19
            )

        [course_name] => Array
            (
                [0] => 
                [1] => Advanced Freediver
            )

        [course] => Array
            (
                [0] => 
                [1] => 19
            )

        [date] => Array
            (
                [0] => 
                [1] => 05/03/2019
            )

        [instructor] => Array
            (
                [0] => 
                [1] => Camila Amor
            )

        [school] => Array
            (
                [0] => 
                [1] => Apnea Total Headquarters
            )

        [pdf_card_id] => Array
            (
                [0] => 
                [1] => 19
            )

        [pdf_dip] => Array
            (
                [0] => 
                [1] => 19
            )

        [last_update] => 21-03-2019
    )

[1] => Array
    (
        [course_id] => Array
            (
                [0] => 
                [1] => 22
            )

        [course_name] => Array
            (
                [0] => 
                [1] => Master Freediver
            )

        [course] => Array
            (
                [0] => 
                [1] => 22
            )

        [date] => Array
            (
                [0] => 
                [1] => 08/03/2019
            )

        [instructor] => Array
            (
                [0] => 
                [1] => Andres Alegria
            )

        [school] => Array
            (
                [0] => 
                [1] => Vertical Dreamers
            )

        [pdf_card_id] => Array
            (
                [0] => 
                [1] => 22
            )

        [pdf_dip] => Array
            (
                [0] => 
                [1] => 22
            )

        [last_update] => 21-03-2019
    )   

0 个答案:

没有答案