Assign role based on email
-
I am trying to assign a role after registration based on email. For example, employees at my company have email accounts of type [email protected]. What I am looking for is that according to the name a specific role is assigned.
This is my code:
if ( ! function_exists( 'actualizar_rol' ) ) { function actualizar_rol(int $user_id) { list($usuario, $dominio) = explode('@', $args['user_email'] ); if ($usuario == 'marcelo.herrera') { wp_update_user( [ 'ID' => $user_id, 'role' => 'rrhh', ] ); } } add_action( 'rtcamp.google_user_created', 'actualizar_rol', 10, 2 ); }
What am I doing wrong?`
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Assign role based on email’ is closed to new replies.