How to update user meta for multiple meta_key in wordpress

前端 未结 2 522
南笙
南笙 2021-01-05 17:38

I\'m trying to update multiple meta_key for user in WordPress

update_user_meta( $user_id, array( \'nickname\' => $userFirstName, \'first_name\' => $us         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-05 18:03

    just try to add the value with the same meta key,and remember to set the third value to false just like

    add_user_meta( $user_id , $meta_key , $value1 , false );
    add_user_meta( $user_id , $meta_key , $value2 , false );
    add_user_meta( $user_id , $meta_key , $value3 , false );
    

    then when you get user meta with the meta key ,it will return like:

    ['$value1','$value2','$value3']
    

提交回复
热议问题