Here is what you need to do:
function set_user_rcp_default_subscriber($user_id) {
$user = new WP_User( $user_id );
foreach( $user->roles as $role ) {
if ( $role === 'subscriber' ) {
update_user_meta( $user_id, 'wp_user_level', '0' );
update_user_meta( $user_id, 'rcp_subscription_level', '1' );
update_user_meta( $user_id, 'rcp_status', 'active' );
update_user_meta( $user_id, 'rcp_expiration', '2014-06-30' );
}
}
}
add_action("user_register", "set_user_rcp_default_subscriber", 10, 1);
We need to loop through it because potentially a user can have multiple roles.
Related Posts:
- wp_update_user not updating
- Create custom user role (client) that can create another custom user role (employee) of that client
- How to loop through each user id?
- Ordering users of a specific role by last name
- how to add custom user capabilities using add_user_meta or something else?
- WordPress missing user roles on local dev machine. Live site works fine
- Assign second role to user
- Display user meta by different user role
- Parent User and Child User – relate users
- Assign a role to the user who registers on a form
- How to create user specific pages (not user role!)?
- How to change user role using hook
- Check role of Username then echo something if administrator [closed]
- Problems using ‘add_role’
- Change auth_cookie_expiration for specific roles and specific login times
- Saving user meta “member_id” based on user role
- Why does user_can return false for a capability during plugin deactivation?
- Hide user fields based off capability
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- How to assign a custom gender to a user role?
- add_role() run only once?
- REST API, get user role?
- Is WordPress’ is_user_logged_in() secure?
- Allow user to Publish, but not Edit or Delete
- Custom Post Type’s Capabilities map_meta_cap issues
- Adding multiple user roles dynamically
- Author Role – Allow editing of Gallery images
- What is the difference between “create_users” and “add_users” capabilities?
- Conditional Tags for Membership Levels when using Wishlist Member Plugin?
- Allow user to edit specific user with meta key using map_meta_cap
- How to remove sticky post capability for a specific user role?
- Let new user role to ‘edit_others_posts’ of other user role, not of its own type
- How to restrict access to specific pages on the back-end?
- User registration approval based on role selected
- add_menu_page() for more than one user role
- How do I turn off the Admin Bar for all Subscribers?
- Hide from specific role the top admin bar new button
- exclude roles from overview
- How do I remove the Other Roles field (from User Role Editor plugin) in wp-admin/user-new.php
- New user created as Participant rather than Contributor [closed]
- How can I disable the update notice for non-administrators?
- How to allow user to edit post in wordpress
- wordpress editor role remove all but ‘menus’ in appearance menu
- Where are the WordPress capabilities stored?
- Conditional tag based on the role of author in author.php
- Custom user roles for access to specific parts of the site
- allow non logged in user to upload images in media library
- How can I add a custom role capability to use in a custom plugin?
- DISALLOW_FILE_EDIT constant being ignored
- Add a button or radio box that update the user role
- User roles are changing automatically
- User restricted only show posts assigned to current user
- Custom Capabilities for CPT and Problem with current_user_can()
- Which capabilities are available in Gravity Forms Salesforce plugin? [closed]
- Woocommerce Wcvendors – duplicate emails when Vendor approved
- Hide front-end from every logged out user and redirect them to the default login page
- Shortcode for Listing Users from Meta Value?
- ‘upload_mimes’ filter seems to be restricting viewing/downloading as well
- Allow user edit widgets
- allowing subscriber role to delete their own posts
- Let users edit their role from the frontend
- Let editors view post in admin but not be able to perform a save/edit
- Capabilities don’t add
- Show menu in sidebar if on specific page AND specific user role (is_page, current_user_can)
- Conditional Tag for Wishlist membership. If the user is added to two levels show particular content
- Is there a capability/User role plugin that lets you specify edit ‘posts’ not ‘custom posts’? [duplicate]
- Adding all custom capabilities to admin
- On action, change user role
- User role and capablities only for 1 plugin
- How to give plugin access to specific role(s)
- Add a second role when registering programmatically
- Is there a way to allow users with “Subscriber” user role to access media library in backend and frontend
- current_user_can( ‘edit_user’ ) does not work
- Conditional editing CPT – using editor’s role and author’s usermeta
- grant multiple roles access to specific admin menu item
- Change role in maintenance mode
- What would cause wp_insert_user role to work sporadically?
- How can I add capability to multiple roles?
- How to Moderate Edits to User Profiles?
- Blank Screen Edit Page when using Editor Role
- Check what capabilitie(s) an action requires
- Add another role to a user when they click a button?
- Give a user role capability to create orders for clients
- dynamic home page according to role user
- Custom site role cannot access Appearance menu
- Restrict content piece by role – Protection message in content?
- Custom Admin Menu Order for all User Roles
- Custom Role Allowing Things It Shouldn’t Be
- Force “submit for review” on update?
- Custom Role accessing the wp-option table
- used code below to allow Editor access to menus – but change permanent, how do I revert?
- Allow users to change author of post
- Display based on specific user
- Is it possible to restrict a specific user to edit a specific custom post.
- Is there a way for a limited user to just view the page of a post without being able to edit it?
- How do I make a draft post accessible to everyone?
- Creating Custom user type just like custom post
- Set user role based on invitation code
- WordPress users roles wp-admin
- User roles empty