If you need to get the value of a field in a custom database table you can try using an SQL query. You’ll have to check the column or table name to construct final version of the query.
add_action( 'profile_update', 'my_profile_update', 10, 2 );
function my_profile_update( $user_id, $old_user_data ) {
global $wpdb;
$status = $wpdb->get_var( $wpdb->prepare(
" SELECT rcp_status FROM rcp_membership WHERE ID = %d ",
$user_id
) );
if( $status == "expired") {
$new_role = array( 'bbp_blocked' => 1 );
$data = serialize( $new_role );
$updated = update_user_meta( $user_id, 'wp_capabilities', $data );
// check and make sure the stored value matches $new_role.
if ( $data != get_user_meta( $user_id, 'wp_capabilities', true ) ) {
wp_die( __( 'user role not updated', 'textdomain' ) );
}
}
}
Related Posts:
- Can I Create a Second Admin Level User Role?
- Allowing users to edit only their page and nobody else’s
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- Hide Admin Menu for Specific User ID who has administrator Role
- Allowing an email as the username?
- Grouping users under parent user
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Front end user meta options for users
- How to customize wp_signon()
- Can I create users that have access to *some* other users posts instead of all other users posts?
- Set default page for user account in admin
- Log all users out of all locations after 24 hours
- Hide everything on site for visitors except specific page IDs
- Managing Users and Creating Groups [closed]
- How to disable a specific page for a specific user
- Are User Levels Still Currently Used?
- Updating wp_user_level on user update
- wordpress user roles are not working
- Displaying different in-page content to cliente/admin
- Problem with automatic role change through cron job
- How can I allow an User to publish only 5 posts per month?
- Where are $current_user->allcaps set?
- Allow admins to login as other users
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- how do I add role and capability after I create a new user
- WordPress user role with create user capability?
- Hook into add_user_role and update based on new and removed roles
- How to Moderate Edits to User Profiles?
- In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
- Custom User Role: Can Edit Own Page, Cannot Create New
- WordPress install checking permissions of user id 0
- Allowing users to edit only their page and nobody else’s
- How to bulk change user role to “No role for this site”
- Restrict Access to the User Profile
- Username has been exposed
- Creating Custom user type just like custom post
- Control Category of each user can post
- Limit user access to installing/configuring a plugin?
- MySQL query to list users who never signed in
- How to remove/limit Editor accounts privileges, to prevent them from deleting media and pages created by Admin
- How to add default folders to Every registered User when registered in WordPress site?
- If the current user is an administrator or editor
- Editor can create any new user except administrator
- How to allow an user role to create a new user under a role which lower than his level only?
- user_login vs. user_nicename
- How to programatically change username (user_login)?
- Remove Ability for Other Users to View Administrator in User List?
- Difference between update_user_meta and update_user_option
- Find out if logged in user is not subscriber
- get_user_meta() doesn’t include user email?
- Groups of capabilities: users with multiple roles?
- User-edit role setting distinct from wp_capabilities? [closed]
- How to restrict access to uploaded files?
- wp_update_user not updating
- Automatically delete inactive users after 2 months
- Check if user is admin by user ID
- alphabetically order role drop-down selection in dashboard
- Execute a function when admin changes the user role
- How to let contributors to create a new revision(draft) editing their published posts
- What the user_status column?
- How to hide media uploads by other users in the Media menu?
- Show admin bar only for some USERS roles
- How to display custom user meta from registration in backend?
- Check if specific username is logged in
- How to update user role without logout
- How to create a template for a custom URI associated with the user
- How to order users alphabetically by their last name?
- How to check user role without using current_user_can()
- Post list based on the user that is logged in
- How do you add a custom option to user data?
- Extending WP_User class and using this sub-class during the whole lifecycle
- Basic auth WordPress REST API dilemma
- Do not allow users to create new posts and pages
- Wp_User_Query not sorting by meta key
- How we can get the user id by its display_name
- WP_User_Query with combined meta query – not working?
- How to use hyperdb to separate and share a user dataset between wordpress installs?
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- Show Biographical Info while creating new user
- How to enable the theme editor cap for an editor role?
- How to assign capabilities to user NOT to User Role
- How to assign an additional/extra/second user-role to multiple users (of a specific user-role)
- How to stop a user from updating the post date
- include user profiles in search results?
- how to add custom user capabilities using add_user_meta or something else?
- How to add follow functionality to multi-author wordpress site?
- BuddyPress | Check if user is in current group [closed]
- Copy a user from one WordPress site to another
- Search multiple meta keys at once
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Return ID of authors who have at least one post
- Where to Store Custom User Fields
- Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that
- Querying Email Addresses for a List of Users with Same Last Name?
- User profile custom field
- WordPress edit_user_profile_update update secondary role
- How do I properly format the user_role array?
- How-to Delay The Capability To Publish Posts?
- ACF Upload Image in front-end with custom form
- Is there a simple way to manage capabilities per user?