@champsupertramp I was able to get the approval portion working using this code below:
add_action( 'um_post_registration_pending_hook', 'check_for_promo_code', 10, 2 );
function check_for_promo_code( $user_id, $args ) {
global $ultimatemember;
um_fetch_user( $user_id );
$promo_codes = array('ecss_amp', 'ECSS_AMP');
$user_promo = um_user('promo_code');
if (in_array($user_promo, $promo_codes )) {
um_fetch_user( $user_id );
UM()->user()->approve();
} else {
um_fetch_user( $user_id );
UM()->user()->pending();
}
}
However, I am unable to successfully set the users role within that same function. I am trying to use the set_role() method as such:
add_action( 'um_post_registration_pending_hook', 'check_for_promo_code', 10, 2 );
function check_for_promo_code( $user_id, $args ) {
global $ultimatemember;
um_fetch_user( $user_id );
$promo_codes = array('ecss_amp', 'ECSS_AMP');
$user_promo = um_user('promo_code');
if (in_array($user_promo, $promo_codes )) {
um_fetch_user( $user_id );
UM()->user()->set_role('role_name_is_here');
UM()->user()->approve();
} else {
um_fetch_user( $user_id );
UM()->user()->pending();
}
}
Does this need to be handled in a separate filter or action? Any tips are greatly appreciated! Thanks!