Created
May 2, 2017 21:46
-
-
Save kcrusher/beeb951e062b1ffb84964d603bc53a6a to your computer and use it in GitHub Desktop.
Gravity Forms Update User - Change role if product registered
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
// Gravity Forms Update User --> Change role if product registered | |
add_action( 'gform_user_updated_10', 'change_role', 10, 4 ); | |
function change_role( $user_id, $feed, $entry, $user_pass ) { | |
$serialfield = rgar( $entry, '28' ); // Field ID 28 - Serial Number - of My Profile form | |
if ( ! empty( $serialfield ) ) { | |
//update role | |
$user_obj = new WP_User( $user_id ); | |
$user_obj->remove_role( 'subscriber' ); | |
$user_obj->add_role( 'registered_owner' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment