User Roles in multisite – odd behavior

Nikolay Can’t comment on my own question, so I guess that giving a loose answer is the best and only way to get back to you. How I’m getting the roles: $user = get_user_by(‘login’, ‘newuser’); $user_meta = get_userdata($user->ID); $user_roles = $user_meta->roles; I do not use any plugin. Fresh WP multisite. I also tried a small … Read more

How do I restrict a second admin certain access?

I think this code will prevent certain users from getting into any part of the admin area (not tested): add_filter(‘admin_menu’, ‘block_users’); function block_users() { $current_user = wp_get_current_user(); // get current user object $allowed_user=”[email protected]”; // change to allowed user email if (! $current_user->user_login == $allowed_user) { wp_redirect(admin_url()); // redirect to dashboard exit; // to exit this … Read more

Obtain wordpress user role

I wanted the logged in user to get one form from other application only if he/she is Administrator and here is how I checked it. You can check for any role (even new role made through custom user role). <? require($_SERVER[‘DOCUMENT_ROOT’].’/wp-load.php’); //to load from any folder $current_user = wp_get_current_user(); $user_info = get_userdata($current_user->ID); if (in_array(“administrator”, $user_info->roles)) … Read more

Custom User Role – can’t edit or publish pages?

Just add the below code your current active theme. Remove the add_action & functions. Just paste below code $result = add_role( ‘client’, __( ‘Client’ ), array( ‘read’ => true, ‘edit_pages’ => true, ‘edit_posts’ => true, ‘edit_published_pages’ => true, ‘edit_published_posts’ => true, ‘edit_others_pages’ => true, ‘edit_others_posts’ => true, ‘publish_pages’ => true, ‘publish_posts’ => true, ‘upload_files’ => … Read more

Change user role based on total number of items ordered

You are using a wrong Parameter ‘$customer_id’ that is not defined in your code. Check below is updated code. It should be work. replace below code with your function. function change_role_on_purchase( $order_id, $order ) { $user_id = $order->get_customer_id(); $user = new WP_User( $user_id ); $purchases = get_user_total_purchased_items( $user_id ); if( $purchases >= 50 && $purchases … Read more

Disable plugin for administrator

I just tested your code and it works, so it seems one of the two following things. You are placing the code in the wrong place, make sure you put that code at the bottom of the functions.php file of your theme. Or maybe the functions.php file of your theme is having problems, in which … Read more

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