How to check user role?

Looking around Google for a few minutes yielded several promising results. Here’s a more detailed one adapted from a snippet on The Code Collective: function get_user_roles( $user_id ) { $user_roles = []; $user = get_userdata( $user_id ); $capabilities = $user->{$wpdb->prefix . ‘capabilities’}; if ( !isset( $wp_roles ) ) { $wp_roles = new WP_Roles(); foreach ( … Read more

Menu page with list of users

As a plugin all that I can give to you is this. <?php /* Plugin Name: Users Table Plugin URI: http://www.exe.ie Description: A list of all available users with their ID, Name, Registration Date, Nickname, User Level and User Role Version: 1.0 Author: Daniel Conde Author URI: http://www.exe.ie License: GPL */ add_action(‘admin_menu’, ‘my_user_table_menu’); function my_user_table_menu() … Read more

Can a Plugin Override New User Default Role Type

You can use the user_registration action to set a custom role directly after wp_insert_user() has been called. add_action(‘user_register’, ‘foo_set_new_user_role’, 9999, 1); function foo_set_new_user_role($user_id){ $user = new WP_User( $user_id ); $user->set_role(‘your_new_role’); } You can also use the action profile_update for just that, profile updates. It takes two parameters $user_id and $old_user_data. Hope this helps you out.

WordPress Remove Submenus

Replace all occurrences of $current_user->user_login == ‘username’ with in_array(‘editor’, $current_user->roles). And you can remove the call to get_currentuserinfo(); as for the user information is available from the global variable $current_user. Here’s a code swap: add_action(‘_admin_menu’, ‘remove_editor_submenu’, 1); function remove_editor_submenu() { global $current_user; if(in_array(‘editor’, $current_user->roles)) { remove_action(‘admin_menu’, ‘_add_themes_utility_last’, 101); } } add_action(‘admin_init’, ‘remove_theme_submenus’); function remove_theme_submenus() { … Read more

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