Dropdown of user roles that depend on variable

1: $billing_company will return user billing_company whatever it is. 2: In $args you are supposed to put an array of user roles to fetch. If you don’t know user role then you can use global var global $current_user; and $user_roles = $current_user->roles; to get all current user roles, so it would be $args = array( … Read more

Custom User Role – can’t edit or publish pages?

Just add the below code your current active theme. Remove the add_action & functions. Just paste below code $result = add_role( ‘client’, __( ‘Client’ ), array( ‘read’ => true, ‘edit_pages’ => true, ‘edit_posts’ => true, ‘edit_published_pages’ => true, ‘edit_published_posts’ => true, ‘edit_others_pages’ => true, ‘edit_others_posts’ => true, ‘publish_pages’ => true, ‘publish_posts’ => true, ‘upload_files’ => … Read more

Switch role on submit button

The exact solution depends on how you create a team. You will have to hook into that action. Supposing that creating a team is done by creating a post of the custom type “team” you would hook into save_post_team, leading to something like this: add_action (‘save_post_team’, ‘wpse314398_change_team_captain_role’, 10, 3); function wpse314398_change_team_captain_role ($post_id, $post, $update) { … Read more

Enable plugins for a specific user role

You can try something like this if ( is_myrole() ) { add_action( ‘some_menu’, ‘my_plugin_menu’ ); } function my_plugin_menu() { add_options_page(‘My Plugin Settings’, ‘My Plugin’, ‘manage_options’, ‘my-plugin-settings’, ‘my_plugin_admin_page’); }