I am trying to grammatically assign second 'seller' to user when the Woocommerce transaction is completed. I know that:

wp_update_user( array( 'ID' => $user_id, 'role' => 'seller' ) );

will change the role but how about adding the new one to existing serialized array. What I need in wp_capabilities is a:2:{s:7:"partner";b:1;s:6:"seller";b:1;}

Thank you!


If you first fetch a WP_User object with get_userdata(), you should then be able to add your additional role with the add_role() method, like so:

$user = get_userdata($user_id);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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