How to update wp_capabilities?
-
I want to assign another role to a user.
I understand the data is stored in the usermeta table in the metakey: wp_capabilities.
The data is serialized, such as:
a:1:{s:13:”administrator”;b:1;}The method I used to update is:
update_user_meta($userid, $metakey, $value);I have used maybe_serialized() to serialize the $value of one of these:
array(‘contributor’,’seller’) and
array(‘contributor’=>1, ‘seller’=>1) and
array([contributor]=>1, [seller]=>1)
without any success.The user wp_capabilities is updated and serialized, but it seems storing the wrong value.
If I use this tool to unserialize
https://blog.tanist.co.uk/files/unserialize/
it won’t show the correct array back.I have searched everywhere but no page can explain how to do it correctly.
And I can’t find the answer on wordpress codex either.
Does anyone how to update wp_capabilities of a user, or any other method to assign another role to a user?
- The topic ‘How to update wp_capabilities?’ is closed to new replies.