Site icon Hip-Hop Website Design and Development

Add function selector to customized registration web page

I’ve sucessfully built-in this code in features.php

//1. Add a brand new kind ingredient...
add_action( 'register_form', 'myplugin_register_form' );
perform myplugin_register_form() {

international $wp_roles;

echo '<label for="function">Kind de shopper</label>';
echo '<choose identify="function" class="enter">';
foreach ( $wp_roles->roles as $key=>$worth ) {
   // Exclude default roles similar to administrator and many others. Add your personal
   if ( in_array( $worth['name'], [ 'Client', 'Entreprise'] )) {
      echo '<possibility worth="'.$key.'">'.$worth['name'].'</possibility>';
   }
}
echo '</choose>';
}

//2. Add validation.
add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );
perform myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) {

if ( empty( $_POST['role'] ) || ! empty( $_POST['role'] ) && trim( $_POST['role'] ) == '' ) {
     $errors->add( 'role_error', __( '<sturdy>ERROR</sturdy>: It's essential to embrace a job.', 'mydomain' ) );
}

return $errors;
}

//3. Lastly, save our further registration person meta.
add_action( 'user_register', 'myplugin_user_register' );
perform myplugin_user_register( $user_id ) {

$user_id = wp_update_user( array( 'ID' => $user_id, 'function' => $_POST['role'] ) );
}

and it really works as anticipated on default WP registration web page.

The theme I exploit for my projet has a customized modal login/signup window and I wish to have this code working on this window as nicely.

See default registration window : https://capricesdelectables.com/wp-login.php?motion=register

See customized login field : https://capricesdelectables.com (click on on “Connexion” high proper pink hyperlink)

This modal window is templated in a particular mytheme-login.php file

How ought to I name the code from features.php to make that displayed on this modal window ?

Thanks