Show menu in sidebar if on specific page AND specific user role (is_page, current_user_can)

Changed the code in functions.php to this: function get_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; } And in the sidebar.php: <?php if (is_page(array(‘page1’)) && get_user_role(‘Administrator’)) : echo ‘<div class=”widget-title”>Title 1</div>’ . wp_nav_menu(array(‘theme_location’=>’menu1’ )); elseif (is_page(array(‘page2’))) : echo ‘<div class=”widget-title”>Page 2</div>’ . wp_nav_menu(array(‘theme_location’=>’menu2’ )); elseif (is_page(array(‘page 3’))) : echo ‘<div class=”widget-title”>Page … Read more

List of users with email and role

That’s the correct way to get what you need. Though I’m not sure why WordPress returns an array of roles since ( to my knowledge ) you can only have 1 role at a time. Roles being an array you can modify by just retrieving the role index 0: $blogusers = get_users(); // Array of … Read more

Let editors view post in admin but not be able to perform a save/edit

How about remove_meta_box( $id, $page, $context );? https://codex.wordpress.org/Function_Reference/remove_meta_box This will remove the Publish meta box which contains the save button… function disable_save() { if( !current_user_can( ‘edit_post’ ) ) { // Or whatever check you need to make remove_meta_box( ‘submitdiv’, ‘your-chosen-post-type’, ‘side’ ); } } // disable_save add_action( ‘admin_menu’, ‘disable_save’ );

How to change a user’s role depending on date registered?

Close, your date comparison is slightly off – user_registered will be a MySQL datetime, so your string comparison will never evaluate true. Instead, convert it to just the date: $registered = mysql2date( ‘Y-m-d’, $user->user_registered ); Now we’re talking: if ( ‘2015-10-01′ === $registered ) { // chocks away } Update: Here’s a complete snippet that … Read more

Let users edit their role from the frontend

You could make a widget that updates the role: Widget has a drop down select input Select input submits a Ajax call to backend Backend Ajax call processor updades the user meta Pass the User ID along with the role ID Update user meta with update_user_meta( $user_id, $meta_key, $meta_value, $prev_value )

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