New answers tagged

0

RESOLVED!! It was me missing a trick within Role Scoper. All sorted! Thanks Mukto90 and Monkey Puzzle for your input. Cheers! Andy


0

Sorry mukto90. That didn't work. I added the following to functions.php add_action('admin_menu', 'edit_trustees_page'); function edit_trustees_page() { global $submenu; $trustees_page_id = 7336; //change this value $url = get_admin_url() . 'post.php?post=' . $trustees_page_id . '&action=edit'; $submenu['index.php'][] = array( 'Edit ...


0

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() . ...


0

This list of filters at the top of admin screens are called Views. You can manage views using the views_{$this->screen->id} filter. Where you'd replace {$this->screen->id} with the name of the screen you'd like to manage. In order to filter the Users screen, you can try the following: // filter the 'users' views add_filter( "views_users", ...


2

1) Install & network activate User Role Editor plugin from http://example.com/wp-admin/network/plugins.php 2) Then go to Settings > User Role Editor menu on network and make sure you have the settings as shown in following screenshot. 3) Go to "User Role Editor" settings page on your main site ...


0

Jevuska is answer is corrected below detail of code check user role current user and display content conditionally. if ( is_user_logged_in() ){ $current_user = wp_get_current_user(); $roles = $current_user->roles; $level = 0; foreach( $roles as $role ){ if( in_array( array( 'administrator', 'shop-manager', 'adoption-agency'), ...


1

Your problem is that current_user_can() takes a capability not a user role. So, to check for an administrator, for example, you might use: if ( current_user_can( 'manage_options' ) ) { ... } because ordinarily only admins can manage options. You'd have to tie your custom user roles to capabilities that correspond to their roles, which are defined for ...


0

Run this once, it will be saved in database. You can run it once by adding it to functions.php and reloading the site once. $user = new WP_User( $user_id ); // the user id you want to have that capability $user->add_cap( 'edit_others_posts' ); // or any other capability that you want


1

use the profile_update hook and in the hooked function, run this check to make sure that it's adding the previous data to the users profile on update too. if ( $update ){ do_action('profile_update', $user_id, $old_user_data); }else{ do_action('user_register', $user_id); } return $user_id; This answer can help you understand it more: ...


-1

$WP_array = array ( 'user_login' => $username, 'user_email' => $email, 'user_pass' => $password, 'user_url' => $website, 'first_name' => $first_name, 'last_name' => $last_name, 'nickname' => $nickname, 'description' => $bio, ) ; ...


1

option 1 is definitely easier and less prone to errors/accidents than changing publish settings every time an author changes roles. To do so globally you should add a filter to the_content (and other content items in your page/post loops) which checks for the author's role and return some text to inform the viewer that the content is not currently ...


2

Interesting functionality, you will need something that does this: Will need to use the hook set_user_role to detect when user role change Then will need to query all posts from that user Then use wp_update_post to change the post status


0

Just more exmple : function allow_tags_content() { global $allowedposttags, $allowedtags; $allowedposttags['div']['data-hello'] = true; $allowedtags['div']['data-hello'] = true; $allowedposttags['div']['data-world'] = true; $allowedtags['div']['data-world'] = true; } add_action('init','allow_tags_content');


1

I just found a very simple solution. If you haven't already - install some form of a capabilities manager plugin. Then, create a new capability from within the capabilities manager - call it "CUSTOM_CAPABILITY_NAME" or whatever you want. Then assign it to a specific role or user. Important: copy and backup and file you intend to modify in case you f*ck ...


0

With @kaiser's answer I found you'll need to utilize admin_menu hook over admin_init as it fires before the !user_can_access_admin_page() check in wp-admin/includes/menu.php otherwise if the user doesn't have 'read' access to the dashboard they'll just get the 'You do not have sufficient permissions to access this page.' page rather than being redirected.


0

I think !isset is a more reliable way of testing so I added that: add_filter( 'registration_errors', 'odin_registration_errors', 10, 3 ); function odin_registration_errors( $errors, $sanitized_user_login, $user_email ) { if ( !isset( $_POST['role'] ) || empty( $_POST['role'] ) || trim( $_POST['role'] ) == '' || ...



Top 50 recent answers are included