Display Custom Field for a Specific Role, but not for Admin

You can use the WP_User class and the has_cap($role) method. The show_user_profile action passes a WP_User object as a parameter to the called function. http://codex.wordpress.org/Class_Reference/WP_User#has_cap.28.24cap.29 add_action(‘show_user_profile’, ‘my_add_extra_profile_fields’); function my_add_extra_profile_fields($user) { if ($user->has_cap(‘subscriber’)) { //Code here } }

Downgrade admin account by mistake

Usually, this should help: Open your database (with phpmyadmin, navicat, etc) Open the wp_user table and have a look for the ID of your admin user (usually 1) Open the wp_usermeta table and search for the row that has the user_id of your user paste the following string into the meta_value field of the row: … Read more

how to remove some permissions from a shop “manager role” in woocommmerce?

This is treading very close to being off-topic as it asks specifically about a particular plugin, but the answer is quite generic: You can remove the capabilities you don’t need. function remove_cap_wpse_186316(){ remove_cap( ‘yourwoorole’, ‘yourwoocap’ ); remove_cap( ‘yourwoorole’, ‘yourwoocap1’ ); } add_action( ‘admin_init’, ‘remove_cap_wpse_186316’ ); The above is code is for demonstration/experimentation only. Note the … Read more

How can I promote a user to a network administrator?

You might use grant_super_admin() To add an admin by user ID you can use grant_super_admin. Simple put grant_super_admin in your theme’s functions.php file (usually in /wp-content/themes/CURRENT THEME NAME/functions.php). You’ll need to put the ID of the user as a variable, the example below we’re using the user ID of 1. grant_super_admin(1); https://drawne.com/add-super-admin-wordpress-network/ Or Some variation … Read more

Role can edit just one page [closed]

Adminimize does not remove menu items etc, it just keeps them visually hidden. In other words, your admin pages is still accessible. Add this code to your functions.php file: add_action(‘admin_menu’, ‘edit_trustees_page’); function edit_trustees_page() { global $submenu; $trustees_page_id = 1; //change this value $url = get_admin_url() . ‘post.php?post=” . $trustees_page_id . “&action=edit’; $submenu[‘index.php’][] = array( ‘Edit … Read more

Restrict Access in Admin Panel

I believe the correct solution here is to just update the $capability component of the admin_menu items rather than just remove them from the menu structure. Try this: /** Set ‘administrator’ cap for particular menu items **/ function update_admin_menu() { global $menu, $submenu; $menu[10][1] = ‘administrator’; // Media foreach( $submenu[‘upload.php’] as &$item ) { $item[1] … Read more

Custom Role with Own Page Edit Capability

I’ve managed to solve this with a little bit of “patching” and thanks to the explanation on both these threads: Remove ability to access certain admin menus & Hide Admin menus per role in WordPress I added to the restrict_menus function the items which access I needed forbidden, and hid in the remove_menus the list … Read more

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