remove/hide pages from users backend

One way to achieve this is by looping through the parent pages and fetching their respective children pages ids. The resulting arrays can then be merged and used in the ‘post__not_in’ variable. add_filter( ‘parse_query’ , ‘exclude_pages_from_admin’ ); function exclude_pages_from_admin( $query ) { global $pagenow,$post_type; $pages = array(‘1′,’2′,’3’); foreach ( $pages as $parent_page ) { $args … Read more

How to get an array of user roles with or without a specific capability?

Try with this: function get_roles_that_cant($capability) { global $wp_roles; if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $available_roles_names = $wp_roles->get_names();//we get all roles names $available_roles_capable = array(); foreach ($available_roles_names as $role_key => $role_name) { //we iterate all the names $role_object = get_role( $role_key );//we get the Role Object $array_of_capabilities = $role_object->capabilities;//we get the array … Read more

Allow Author on Site A capability to upload files on Site B in Multi Site

Look into switch_to_blog() and its required follow up, restore_current_blog() I left comments in code for basic idea to adapt into your function. It may need tweaking, and can probably be improved. //Site B add_action( ‘init’, ‘site_a_author_upload_site_b’ ); function site_a_author_upload_site_b() { if ( is_user_logged_in() ) { //get a WP_User object of current user $current_user = wp_get_current_user(); … Read more

Query users which have same dynamically generated roles as the current user

To achieve this, you first need to get all the current user roles, X and Y(s)… function get_current_user_roles(){ global $wp_roles; $current_user = wp_get_current_user(); $user_groups = groups_get_user_groups( $current_user->ID ); $user_roles = isset( $current_user->roles[‘X’] ) ? array( ‘X’ ) : array(); // Let’s get all Y dynamic user roles… foreach ( $user_groups[‘groups’] as $id ) { $group … Read more

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