Get role/s of current logged in user in ASP.NET Core MVC

You may want to consider trying to load the actual ApplicationUser object via the FindByEmail() or some other method and passing that object into the GetRolesAsync() method as seen below : // Resolve the user via their email var user = await _userManager.FindByEmailAsync(model.Email); // Get the roles for the user var roles = await _userManager.GetRolesAsync(user); … Read more

AngularJS, ui.router, load template and controller based on user role

Loading template and controller based on user role While technically ui-router templateUrl function does not support injecting services you can use templateProvider to inject service that holds role variable or loads it asynchronously and then use $templateFactory to return HTML content. Consider following example: var app = angular.module(‘app’, [‘ui.router’]); app.service(‘session’, function($timeout, $q){ this.role = null; … Read more

Get user role by ID WordPress

To check if a user has a specific role, you have to get a list of their roles and see if the role is listed there. Example function: function user_has_role($user_id, $role_name) { $user_meta = get_userdata($user_id); $user_roles = $user_meta->roles; return in_array($role_name, $user_roles); } Example usage: $user_is_subscriber = user_has_role(get_current_user_id(), ‘subscriber’);

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