Skip to content

Instantly share code, notes, and snippets.

@Jerl92
Created December 26, 2025 15:57
Show Gist options
  • Select an option

  • Save Jerl92/31bf7684c438672e1ba32f74ea5513db to your computer and use it in GitHub Desktop.

Select an option

Save Jerl92/31bf7684c438672e1ba32f74ea5513db to your computer and use it in GitHub Desktop.
Ultimate member change user role on create
<?php
add_action( 'um_registration_set_extra_data', 'my_custom_after_registration_action', 10, 2 );
function my_custom_after_registration_action( $user_id, $args ) {
if ( empty( $user_id ) || is_wp_error( $user_id ) ) {
return;
}
// Check if the specific radio button field value exists in the submitted data
$user = new WP_User( $user_id );
$meta_for_user = get_user_meta( $user_id, 'Status', true );
$meta_user_status = $meta_for_user[0];
$statuts_value = sanitize_text_field( $meta_user_status );
if($meta_user_status == 'Employeur'){
$user->set_role( 'um_employeur' );
}
if($meta_user_status == 'Employer'){
$user->set_role( 'employer' );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment