Either use wp_update_user
wp_update_user(
array (
'ID' => 1, // replace by your user ID
'role' => 'editor'
)
) ;
or the set_role
method of the WP_User
class.
$you = new WP_User( 1 ); // again, replace parameter by your user ID
$you->set_role( 'editor' );
Related Posts:
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- Hide custom post type by user roles
- what’s the meaning of the field wp_capabilities in table wp_usermeta
- Send user activation email when programmatically creating user
- Change default admin page for specific role(s)
- How to check username/password without signing in the user
- How to Change the Entire WordPress Admin panel Look and Feel?
- WordPress REST API call generates nonce twice on every call
- How to Structure a New Role/Capability Scheme?
- How to add more than 1 user role to sub-menu pages
- Custom user profile, registration, login page with theme
- How to use WP default post list tables in a plugin?
- How to allow Unfiltered HTML in a wordpress multisite install
- How to add quick edit and bulk edit fields to users admin section
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- How to not let a user with a new role edit users that have administrator role?
- Execute plugin for specific user role(s) only
- Generating User(s) with Settings API
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- Print WordPress username id inside JavaScript
- query users by role
- Function Get User Object By Username?
- Check if someone is editing a post (this content is currently locked)
- Hide plugin dashboard menu item for specific roles
- Modify users.php page to create page/post on button clicked
- Subscribe to author?
- How to filter users list on user_status field with get_users()
- Frontend language per user
- get_posts() not working when accessing with a custom user role
- Limit role to one plugin [duplicate]
- Display custom fields in frontside user profile
- Logout users upon login, based on caps/role?
- Set different custom menu items for different user roles
- Prevent third party plugin’s admin page access based on user type
- wp_dropdown_roles() to replace option value = code
- global $current_user not current user
- Display list of uploaded images, filtered by user under a specific user group
- What is the proper way to get logged in user id in a plugin?
- How to build a fool proof AdSense revenue sharing model?
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- How to allow only two (or more) users access to a plugin
- First and last name fields not filled when using wp_insert_user
- Wp-admin Custom User Management
- Check user’s role and store in variable
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- get author of published post
- How to get custom post_author?
- Associate multiple email addresses with the same user account, so they can log in with either
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Update a user profile via frontend
- Best practice for Designing a Plugin with this scenario
- Adding another field to user table
- how to get the top 10 popular blogs
- How to relate the Category to user?
- How to determine which capability to use?
- Adding a dropdown on the user admin
- Allowing duplicating users with same user_login and user_email
- Allow contributor user role to perform copy operation PHP
- Why User_login key doesn’t work with wp_update_user()
- How to grab data after wp user search is complete
- Enable a role named ‘backend_user’ to access my plugin pages
- Add custom parameter for custom user role
- How to prevent users from deleting their accounts?
- Buddy Press restrict the capability to edit users
- User Registration Moderate
- How I can give access to my custom plugin for editor roles user?
- How to retrieve custom profile fields associated with different users
- Remove all capabilities in separate method fails versus included in method
- Remove from a div by class name from post page if post author role is not administrator
- Upgrade routine: Interaction with user confirmation
- Adding admin for specific users
- What is more secure checking capabilities of user or checking role of user in WordPress plugin development
- New Users are saved with no role selected
- WordPress User Management Departmental Managers
- Multiple Users Logged In Causing Incorrect Account Returned
- first_name property missing inside register_user action hook
- user can login from single account detail from multiple locations(computer) at the same time [closed]
- Create Unique and Customized User ID for Website Members in WordPress
- Remove default wordpress roles
- How to lock users account until approvation
- How to debug a plugin with Xdebug?
- How to create Image gallery Metabox in wordpress [closed]
- Is it possible to create an action hook using do_action() within add_action()?
- Need specific kind of “Poll Voting” for WordPress [closed]
- Install widget on plugin activation
- Plugin admin page meta_box toggle and order state not saving
- Prevent Javascript Facebook SDK Conflicts in plugin
- Change the ‘published on’ text?
- Gravity Forms Perks – Nested Forms
- Update custom plugin with WP-CLI
- Update wordpress Core Remotely
- Translating plugin settings page – dropdown list
- Hide one specific woocoomerce product
- Groups and subgroups for permission
- GET request return value as error instead of success
- How to update global variables in plugin activation callback?
- How to include a page template and template part into my plugin
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- How to display .ptm file in my WP site without JAVA
- ‘useSate’ error when using React on the frontend in custom block plugin