WordPress remove capability post ,media completely for custom role

Remove a top level admin menu: function custom_menu_page_removing() { remove_menu_page( $menu_slug ); } add_action( ‘admin_menu’, ‘custom_menu_page_removing’ ); To remove only certain menu items include only those you want to hide within the function. To remove menus for only certain users you may want to utilize current_user_can(). You can take a look at https://codex.wordpress.org/Function_Reference/remove_menu_page

WordPress Multisite Add User

Ok, so this isn’t possible to do by default. As I already had a hook for wpmu_activate_blog() I just created another with a lower priority which will be fired after. This function also has the 2 parameters I need. So upon activation of the account I simply remove Admin role and set a new role … Read more

Multisite network admin – User’s role not showing up

This worked for me: Make sure the row in option-table in the database for wordpress-site have the correct option_name for the serialised roles-data. For instance; if the database-table is wp_options, the column option_name in the role-row should be wp_user_roles. if the database-table is wp_20_options, the column option_name in the role-row should be wp_20_user_roles. Don’t ask … Read more

remove_cap nothing changes

Look at the remove_cap method from WP_User class- /** * Remove capability from user. * * @since 2.0.0 * @access public * * @param string $cap Capability name. */ public function remove_cap( $cap ) { if ( ! isset( $this->caps[ $cap ] ) ) { return; } unset( $this->caps[ $cap ] ); update_user_meta( $this->ID, $this->cap_key, … Read more

List all users and current week entries

If by “made an entry” you mean “has published at least 1 post”, then following will do it (with the proviso given below): $args = array ( ‘role’ => ‘spectator’, ) ; $spectators = new WP_User_Query ($args) ; $users_with_recent_posts = array () ; foreach ($spectators->get_results () as $user) { $args = array ( // if … Read more

Noindex subscriber author page

The function you want is get_userdata(). Since you need to do this outside the loop, the process is a little less straight-forward. The first thing you need to do is set up a variable called $curauth which is an object that you create by accessing the database by using the $_GET[] superglobal. $curauth = ( … Read more

Make a single page in WordPress available only for Admin and Subscribers

please try this if ( have_posts() ) : while ( have_posts() ) : the_post(); if ( get_post_status (get_the_id()) == ‘private’ ) { if ( current_user_can( ‘administrator’ ) ) { the_title(); the_content(); } else if ( current_user_can( ‘subscriber’ ) ) { the_title(); the_content(); } else { echo ‘this post is private’; } } else { the_title(); … Read more

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