This allows plugins to easily hijack the default role while they’re active.
// Hijack the option, the role will follow!
add_filter('pre_option_default_role', function($default_role){
// You can also add conditional tags here and return whatever
return 'subscriber'; // This is changed
return $default_role; // This allows default
});
I use it to make sure some plugins that need subscriber roles get it regardless of Administrator attempts to change 🙂
Regards.
Related Posts:
- Menu page with list of users
- How to allow an user role to create a new user under a role which lower than his level only?
- What the user_status column?
- How to loop through each user id?
- How to programmatically add a user to a role?
- Prevent user creating new users with specific roles
- Roles at registration (classipress)
- Order users by custom user meta
- List total number of users that are authors
- Auto Delete Users (auto_delete_users)
- Is there a way to set the user Role based on email domain
- How to customize wp_signon()
- Can’t manage to make translate_user_role() work
- WPMU – new users are automatically subscribed to the main blog – how to prevent that?
- User registration approval based on role selected
- exclude roles from overview
- get approved users only ( ultimate member plugin )
- New user created as Participant rather than Contributor [closed]
- Query users which have same dynamically generated roles as the current user
- Displaying different in-page content to cliente/admin
- How to create user specific pages (not user role!)?
- How to change a user’s role conditionally to expire after two weeks
- Limit number of users a role can create
- How to get a users list by who created them?
- Customising “user ids” and add to ‘user’ panel in the admin area
- How to hide some users to unlogged users [closed]
- List of users with email and role
- How to create a front facing user sign up, log in and profile pages like FoodGawker.Com [closed]
- Add a second role when registering programmatically
- Easily adding multiple existing users to a multisite site
- What would cause wp_insert_user role to work sporadically?
- How to Enable registration email for a custom user role?
- Add role selector to custom registration page
- Multiple user role on registration
- User / membership Plugin [closed]
- Can someone help me out? Why isn’t this working?
- A different role for each site in a multisite
- Select dropdown with 2 choices from foreach
- List users of specific role instead of removing them with specific role
- add user role selection to registration form [duplicate]
- file upload user profile
- How to assign role to a custom registration form?
- User role can’t be set
- User has empty instead of custom role when logged in
- Why are my roles not visible in a Multi-site/Network?
- Allowing users to edit only their page and nobody else’s
- How to remove administrator role in settings -> general -> New User Default Role?
- How can I change a user role upon visiting a page?
- How to let the Contributor role preview unpublished posts?
- Force users to complete their profile after they register? How to
- How-to Delay The Capability To Publish Posts?
- Make certain pages uneditable by editors?
- Contributors missing from author dropdown
- Limit content by user registration date
- What is the best way to avoid spammers registering to my blog?
- Show different badge based upon the user role
- Authenticating to WordPress, using my own authentication two-factor system
- How can I check if the admin bar is visible to the current user?
- Users Role and Access
- Allow contributors to add categories, but not delete
- Hide everything on site for visitors except specific page IDs
- the_author_meta(‘user_url’, $author->ID) not working properly. how can I solve this?
- Assign role to user on first login, if they are first (after admin)
- How to allow a user to make their post (ad) a draft, and then publish again without needing approval?
- Function to allow “Anyone can register”?
- Customized role that allows users to “Submit for Review” instead of “Publish”
- if user has a certain role then display image
- Updating wp_user_level on user update
- Allow WooCommerce existing customers to checkout without being logged in [closed]
- user_profile_update_errors hook not executing
- All users/comments suspected as bot? [closed]
- Add custom role across network in multisite
- bbPress: How to set conditional for specific user -or- user role, to be displayed in user profile
- How to check user role?
- Paypal API and WordPress
- Does wordpress support natively the concept of logging-in users? (not admins, but users of the website)
- Is there a Capability that checks as true for non-logged in users?
- Copy user role on multisite so the user can access subsites with same role
- How to write conditions based on user capabilities not on user role?
- How to hide user profile fields based on the role of the viewed user?
- Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
- Edit text of WordPress “Register” button
- WordPress user role with create user capability?
- Perform multiple actions after wp_insert_user()
- Update user role for expired membership
- Change logo url based on WP user role
- Auto approve new users if their username is included in a predefined list
- Can’t activate a user on multisite install
- Show user details only
- Access level seems to have gone from admin to editor
- Control what custom posts a user can see
- How to create child/sub user under parent user
- Need to create admin user without capability to create user
- Give editor ability to edit custom settings without access to Main Settings
- User register hook can’t access form request
- How to give different user access to different people?
- Hide categories from authors
- MySQL query to list users who never signed in
- Send email to user if their role is changed to Author
- Hardening user’s role after add_role