OpenSanghaFoundation / OSF

Bug/Feature requests tracking and documentation managament
https://opensanghafoundation.org
0 stars 0 forks source link

Users can't be registered via regitster-2 #17

Closed coiby closed 4 months ago

coiby commented 5 months ago

Describe the bug When I tried to register, the following error is shown,

there are errors in registration, this email and user_login are already used. pleas try loging in with password OSF@2023osf

To Reproduce Steps to reproduce the behavior:

  1. Go to https://opensanghafoundation.org/newsite/register-2/
  2. Fill in required fileds

Screenshots Screenshot_2024-05-01_09-29-12

Additional context Add any other context about the problem here.

OSFOSF commented 4 months ago

this message was added to stop folks from using already registered email and user _ligin the message has bee improved but is comes at the wrong place but this is a feature of UM

coiby commented 4 months ago

@OSFOSF UM provides a simple solution for this case i.e. only to allow an unique email for value validatation. I've changed the validation to "Unique Email" now, Screenshot_2024-05-15_18-00-40

For username, "Unique name" validation has already been picked up, Screenshot_2024-05-15_17-51-39

Now the errors will be shown as below when duplicated username or email is submitted, Screenshot_2024-05-15_17-57-20

So absolutely there is no need to add this message which is also quite confusing. Btw, I wonder how did you add this message?

OSFOSF commented 4 months ago

Coiby added it to the page no looks good

coiby commented 4 months ago

@OSFOSF I didn't add the top message "there are errors in registration, this email and user_login are already used". I would try to avoid making a change in this way because this is kind of hacking the system and bypassing UM's logic. Thus it could be error-prone and may also cause headache for future maintenance.

Do you know who may add that message? Because I'm wondering if adding this message may bring an unexpected bug i.e. #38 which can't be reproduced with a clean install of WP+UM.

OSFOSF commented 4 months ago

Hi Coiby this error message at very top was added in case the email or the user_login caused an error,  But you added the code to in the um form to do this checking so the above message should not ever occur now.  the fom should catch this error not the code i wrote as a stop.   On Friday, May 17, 2024 at 10:06:24 PM GMT+7, Coiby @.***> wrote:

@OSFOSF I didn't add the top message "there are errors in registration, this email and user_login are already used". Do you know who may add that message? Because I'm wondering if adding this message may bring an unexpected bug i.e. #38 which can't be reproduced with a clean install of WP+UM.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

coiby commented 4 months ago

According to https://github.com/ultimatemember/ultimatemember/pull/1058, UM won't show message like this email has been registered to improve security. But I think this is a small concern that can be dimissed. So I followed Custom validation email and error message in registration - Ultimate Member which is the official recommend to set up Custom validation email and here is now the message will look like for a duplicate email, Screenshot_2024-05-25_17-55-26

I also clean up themes/maxcoach/functions.php

--- functions_bak.php   2024-05-25 17:50:56.404690058 +0800
+++ functions.php       2024-05-25 17:50:38.251758665 +0800
@@ -494,6 +494,7 @@
     return $items;
 }

+// https://docs.ultimatemember.com/article/1697-email-validation-in-registration
 add_action( 'um_custom_field_validation_user_email_details', 'um_custom_validate_user_email_details', 999, 3 );
 function um_custom_validate_user_email_details( $key, $array, $args ) {
        if ( $key == 'user_email' && isset( $args['user_email'] ) ) {
@@ -1782,39 +1783,6 @@
 add_action('show_user_profile', 'display_career_values_on_edit');
 add_action('edit_user_profile', 'display_career_values_on_edit');

-
-//dhammarato added 10.20.23
-add_action('um_submit_form_errors_hook_', 'dh_custom_code', 10, 1);
-
-// Define the custom code function
-function dh_custom_code($args) {
-// Get the username from the form
-//$username = $args['user_login'];
-/*
-$user_id = um_profile_id();
-um_fetch_user( $user_id );
-if ($user_id < 1){
-echo $user_id;    
-echo "<h3>there are errors in registration, this email and user_login are already used. pleas try loging in with password OSF@2023osf</h3>";
-echo $user_id;       
-}
-$display_name = um_user('display_name');
-$user_logon   = um_user('user_logon');
-echo $display_nasme . ' ' . $user_logon ;
-// Check if the username already exists
-*/
-$username = $args['user_login'];
-if (username_exists($username)) {
-// Display a message
-echo "<h3<h3 style='color: red;'>The username $username is already taken. Please choose a different one. Or try loging in with default password OSF@2023osf.</h3>";
-}
-$email = $args['user_email'];
-if (email_exists($email)) {
-// Display a message
-echo "<h3<h3 style='color: red;'>The email $email is already taken. Please choose a different one. Or try loging in with default password OSF@2023osf.</h3>";
-}
-}
-
 function enqueue_custom_popup_script() {
 wp_enqueue_script( 'custom-popup-script', get_template_directory_uri() . '/js/custom-popup.js', array( 'jquery' ), '', true );
 }