Within the database, where is the flag which says that a user has Super Admin rights?
This is actually stored in the {prefix}sitemeta table. The meta key is site_admins, and it’s a serialized PHP array of usernames.
This is actually stored in the {prefix}sitemeta table. The meta key is site_admins, and it’s a serialized PHP array of usernames.
You could do something like (in your functions.php file); if(current_user_can(‘member’)){ add_filter(‘get_sample_permalink_html’, ‘perm’, ”,4); function perm($return, $id, $new_title, $new_slug){ $post = get_post( $id ); if( ! $post || ( $post->post_type !== ‘testimonials’ ) ) { return $return; } return preg_replace( ‘/<span id=”edit-slug-buttons”>.*<\/span>|<span id=\’view-post-btn\’>.*<\/span>/i’, ”, $return ); } To give credit where credit is due, everything between … Read more
Those names are stored in the option wp_user_roles in the database table wp_options. So, the following will change the name of the subscriber role: $val = get_option( ‘wp_user_roles’ ); $val[‘subscriber’][‘name’] = ‘PeDeBoi’; update_option( ‘wp_user_roles’, $val ); Apparently, this is harmless, but caveat emptor… In your code, $wp_roles->roles[$role][‘name’] = $new_role_name; doesn’t work because it should be: … Read more
You can add actions to the set_user_role hook: add_action( ‘set_user_role’, ‘wpse98904_remove_demoted_user_posts’, 10, 2 ); function wpse98904_remove_demoted_user_posts( $demoted_author_id, $role ) { if( ‘subscriber’ == $role ) { // In here you’d search for all the posts by the user $args = array( ‘numberposts’ => -1, ‘author’ => $demoted_author_id, ‘post_type’ => ‘{your custom post type name}’, // … Read more
From quick look at code the likely permissions check for that is edit_comment capability in edit_comment() function. Your options to remove that capability roughly are: customize the role with plugin, for example Members customize role with code, probably using remove cap functionality filter thiungs around map_meta_cap or user_has_cap if you need to achieve more elaborate … Read more
Have you checked the database for User’s url. Maybe that’s what they used for registering. What about this scenario – For admin, the default value of url is the blog url. User ID 2 used a url when registering. User ID 3 kept the url field blank when registering. You should fist check their url … Read more
wp_insert_user will not create a non-existing user with a set ID, it will return an error. The way to do this would be to first do: global $wpdb; $wpdb->insert( $wpdb->users, array( ‘ID’ => 136166 ) ); wp_insert_user( … ); The code above will first create an empty user row with the set ID (it will … Read more
I think is a better strategy, that you add on the activation a new capability and add this capability to the Administrator role. This makes possible for installations with much different roles to the WP default to add this capability to other roles or for the requirement of a installation to add the view to … Read more
You can simply use WP_User class. $user = new WP_User( $user_id ); foreach( $user->roles as $role ) { $role = get_role( $role ); if ( $role != null ) echo $role->name; } Read more about WP_User
If you want to show a message, use this code in your functions.php file- function se_236335_hide_content( $content ){ $pages = array( 8, 26, 35 ); // allowed page IDs if( ! in_array( get_the_id(), $pages ) ){ return ‘Message here..’; } return $content; } add_filter( ‘the_content’, ‘se_236335_hide_content’ ); If you want a page redirection, use this- … Read more