How can I prevent certain custom roles from seeing other custom roles on the user list page?

Method 1, SQL Notes about your SQL [Unknown column ‘wp_usermeta.meta_key’ in ‘where clause’] This is solved by adding this to the JOIN part of the query: JOIN wp_usermeta ON ( wp_usermeta.user_id = wp_users.ID ) You could check the value of the JOINS and, if false === strpos( ‘wp_usermeta’, $joins ), adding it yourself. When getting … Read more

WordPress custom post type capabilities issue

You definitely need to set map_meta_cap to true instead of false to create custom capabilities. I haven’t seen the ‘capability_type’ => [‘note’,’notes’] way of creating capabilities before – maybe it’s shorthand, but if just changing map_meta_cap doesn’t work, you might want to spell everything out the long way: <?php $args = array( ‘labels’ => $labels, … Read more

How to get a users list by who created them?

I’ve found it. /*** Adding extra field to get the the user who creates the another user during ADD NEW USER ***/ function custom_user_profile_fields($user){ if(is_object($user)) $created_by = esc_attr( get_the_author_meta( ‘created_by’, $user->ID ) ); else $created_by = null; ?> <h3>Extra profile information</h3> <table class=”form-table”> <tr> <th><label for=”created_by”>Created By</label></th> <td> <input type=”text” class=”regular-text” name=”created_by” value=”<?php echo $created_by; … Read more

Remove capability from specific user

the page you linked shows how to remove a capability from a role: global $wp_roles; // remove capability $cap from role $role $wp_roles->remove_cap( $role, $cap ); and an example would be: // for example $wp_roles->remove_cap( ‘subscriber’, ‘view_galleries’ ); or remove a capability from a specific user: // get the user by username say for example … 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