remove menus for a specific role?

Here is your answer: function remove_menus () { global $menu; if( (current_user_can(‘install_themes’)) ) { $restricted = array(); } // check if admin and hide nothing else { // for all other users if ($current_user->user_level < 10) $restricted = array(__(‘Dashboard’), __(‘Posts’), __(‘Media’), __(‘Links’), __(‘Pages’), __(‘Appearance’), __(‘Tools’), __(‘Users’), __(‘Settings’), __(‘Comments’), __(‘Plugins’)); // this removes a lot! Just … Read more

Custom wordpress admin page/url “You do not have sufficient permissions to access this page.”

This is what you need: function my_special_function(){ ?> <div class=”wrap”> <h2>Hello World</h2> <!– ALL THE CUSTOM MARK UP SHOULD BE INSIDE WRAP–> </div> <?php } function my_menu_page(){ add_menu_page(‘Page title’, ‘Menu Title’, ‘administrator’, ‘page_slug’, ‘my_special_function’); } add_action(‘admin_menu’, ‘my_menu_page’); Try this!

List users of an array of roles

Unfortunately, you cannot pass an Array of User Roles to WP_User_Query. The role argument only accepts a String, which is then cleared by a trim command. See user.php on Line 495, where prepare handles the Query for the Constructor after parsing the $args.

How to sync roles across Multisite?

There’s an action hook in the set_role function. It’s a matter of detecting if this is happening in the main site, and, if it does, get all blogs of the user and change all roles. More details in code comments. add_action( ‘set_user_role’, ‘sync_user_roles_wpse_91745’, 10, 2 ); function sync_user_roles_wpse_91745( $user_id, $role ) { // is_multisite() used … Read more

Custom Capabilities for CPT and Problem with current_user_can()

Solved! Meta Capabilities edit_product, delete_product, ‘read_product` etc should be handled separately. Below code is from Justin Tadlocks Site add_filter( ‘map_meta_cap’, ‘fac_map_meta_cap’, 10, 4 ); function fac_map_meta_cap( $caps, $cap, $user_id, $args ) { /* If editing, deleting, or reading a product, get the post and post type object. */ if ( ‘edit_product’ == $cap || ‘delete_product’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)