Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CoachBirgit/d62bdecdeb8357e59cf9 to your computer and use it in GitHub Desktop.
Save CoachBirgit/d62bdecdeb8357e59cf9 to your computer and use it in GitHub Desktop.
/* This example syncs both UM / WP role during user approval */
add_action('um_after_user_is_approved', 'sync_um_and_wp_role', 99 );
function sync_um_and_wp_role( $user_id ) {
// Get UM role
$role = get_user_meta( $user_id, 'role', true );
// Set WordPress role for same user
$wp_user_object = new WP_User( $user_id );
$wp_user_object->set_role( $role );
}
@CoachBirgit
Copy link
Author

/* This example syncs both UM / WP role during user approval */

add_action('um_after_user_is_approved', 'sync_um_and_wp_role', 99 );
function sync_um_and_wp_role( $user_id ) {

    // Get UM role
    $role = get_user_meta( $user_id, 'role', true );

if ( $role == 'hostess' ) {
$wp_user_object = new WP_User( $user_id );
$wp_user_object->set_role( 'hostess');
}

if ( $role == 'models' ) {
$wp_user_object = new WP_User( $user_id );
$wp_user_object->set_role( 'models');
}

if ( $role == 'entertainers' ) {
$wp_user_object = new WP_User( $user_id );
$wp_user_object->set_role( 'entertainers');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment