URL Restrictions? Need only people who are logged in AND have a specific role (or roles) to access all pages for a site
URL Restrictions? Need only people who are logged in AND have a specific role (or roles) to access all pages for a site
URL Restrictions? Need only people who are logged in AND have a specific role (or roles) to access all pages for a site
Block access to plugins.php for custom role
If you need to get the value of a field in a custom database table you can try using an SQL query. You’ll have to check the column or table name to construct final version of the query. add_action( ‘profile_update’, ‘my_profile_update’, 10, 2 ); function my_profile_update( $user_id, $old_user_data ) { global $wpdb; $status = $wpdb->get_var( … Read more
You can use user_register action, which is invoked after registering a new user. To add or remove roles/caps, the WP_User class provides methods: add_cap(), add_role() remove_cap(), remove_role() Your code might look like this: add_action( ‘user_register’, ‘se385135_user_register’ ); function se385135_user_register( $user_id ) { $user = wp_get_current_user(); if ( !isset( $user->ID ) || $user->ID == 0 ) … Read more
You could use the register_new_user hook which fires after the registration is complete. e.g. function add_role_to_new_user( $user_id ) { $new_user = get_userdata( $user_id ); if ( $new_user ) { $new_user->add_role( ‘a_second_role’ ); } } add_filter( ‘register_new_user’, ‘add_role_to_new_user’ ); This will – I think – fire for all new users, including new administrators added in the … Read more
How to give plugin access to specific role(s)
User role and capablities only for 1 plugin
Couple of things perhaps spring to mind – when using add_action you’ll need to provide how many of the arguments you’re planning on using. Default 1. You’re not using request info so get rid of that. Second bit geodir_get_current_posttype() link Read through how the function works and make sure it makes sense and would work … Read more
You can use the remove_menu_page() hook to remove the menu items, but the pages will still be accessible if the user types in the URL. Source: WPMayor To find the ‘contact’ page to remove, grab the slug from the Contact admin page and paste it as the argument as the argument, e.g. remove_menu_page( “[Your admin … Read more
See which user role / capability is needed to use a plugin