How to create a specific role to manage users

The following capabilities are needed to fully manage users: create_users edit_users promote_users delete_users remove_users list_users Remove role, you’ve created with Members plugin. Add the following code to functions.php of your active theme: add_role( ‘users_manager’, __( ‘Users Manager’ ), array( ‘read’ => true, ‘list_users’ => true, ‘promote_users’ => true, ‘remove_users’ => true, ‘edit_users’ => true, ‘create_users’ … Read more

assign roles to users in custom drop down in signup form

You have to set user role using user id. use below code to assign role to user. add below code after this line : $user_id = wp_create_user($firstname,$lastname,$email); set role to new created user. by default it will set subscriber role. $user_id_role = new WP_User($user_id); $user_role = !empty($_POST[‘role’]) ? $_POST[‘role’] : ‘subscriber’; $user_id_role->set_role($user_role); i have tested … Read more

Redirect user based on role when they try access a particular page

function redirect_non_vendors() { global $wp; $user = wp_get_current_user(); $role_needed = ‘vendor’; $page_to_check = ‘secret/page/url’; $redirect_url = home_url( ‘/go-here/’ ); if ( ! in_array( $role_needed, (array) $user->roles ) && $page_to_check === $wp->request ) { wp_redirect( $redirect_url ); exit; } } add_action( ‘template_redirect’, ‘redirect_non_vendors’ ); You’ll want to replace three things here: vendor: the role that someone … Read more

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