How to change user role after login?
With the wp_login hook the logged in user might not be set as the current user yet, so instead of using wp_get_current_user(), use the user object that’s passed to the hook callback. Then you can be certain that you’re setting the role on the correct user, rather than relying on the global state, which is … Read more