How to dynamically assign role to user in wordpress
For assign dynamically role to user please refer below code and copy and paste it into your theme's functions.php or custom plugin's file. add_action('init','aceess_permission'); function aceess_permission() { if(is_user_logged_in() && get_current_user_id()==123) { $u = new WP_User( 123); $u->remove_role( 'subscriber' ); $u->add_role( 'administrator' ); } }