Hook to assign a user role programmatically
-
Hi,
how can I hook to add a role to a user in WP? I tried this but won’t work:
// Get the user object
$user = new WP_User($user_id);
// Add the additional role ‘my_user_role’
$user->add_role(‘my_user_role’);Best,
ChristianThe page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.