Forked from ultimatemember/gist:d98861b4c14a1540291b
Created
February 20, 2016 02:25
-
-
Save ioniacob/41e2ecb609b11803b347 to your computer and use it in GitHub Desktop.
Conditionally sync UM user role based on WP role (Gravity forms)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This code will sync the UM role based on WP role using gravity registration */ | |
add_action("gform_user_registered", "um_gravity_user_role_sync", 200, 4); | |
function um_gravity_user_role_sync($user_id, $config, $entry, $user_pass) { | |
$user = new WP_User( $user_id ); | |
$wp_role = $user->roles[0]; | |
// if WP role is subscriber, set UM role to member | |
if ( $wp_role == 'subscriber' ) { | |
update_user_meta($user_id, 'role', 'member'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment