I want to edit the signup password plugin by making

Hello,

I want to edit the signup password plugin by making the password fields mandatory. How should i go about doing so.

Thanks in advanced.

  • Adam Czajczyk

    Hey Thomas,

    I hope you're well and thank you for your question!

    This will require a little "plugin hack" so please note that the changes may be lost upon possible plugin update. It would be best to note them down to be able to re-apply if needed.

    Inside the "signup-password.php" file you'll find this code around line #131:

    if ( !empty( $password_1 )  && $_POST['stage'] == 'validate-user-signup' ) {
    		if ( $password_1 != $password_2 ) {
    			$content['errors']->add('password_1', __('Passwords do not match.', 'signup_password'));
    		}
    	}
    	return $content;

    Replacing it with the following should do the job:

    if (empty($password_1)) {
    		$content['errors']->add('password_1',__('Password cannot be empty.', 'signup_password'));
    	}
    	else {
    		if ( !empty( $password_1 )  && $_POST['stage'] == 'validate-user-signup' ) {
    			if ( $password_1 != $password_2 ) {
    				$content['errors']->add('password_1', __('Passwords do not match.', 'signup_password'));
    			}
    		}
    	}
    	return $content;

    Let me know please if it helped!

    Cheers,
    Adam

  • Tom Whittaker

    Hey @Adam Czajczyk,

    Just want to point something out, with the latest version of WP, the code give some troubles, because when adding a new user from the dashboard,somehow the filter get a higher priority, so it check if a password is enter while adding a user from the dashboard and as you know the password will have to be generated from there because there's no input field for the password.

    I manage to add a Page conditional statement. here's the updated code in case someone needs it in the future.

    function wpmu_signup_password_filter($content) {
    	$password_1 = isset($_POST['password_1'])?$_POST['password_1']:'';
    	$password_2 = isset($_POST['password_2'])?$_POST['password_2']:'';
    
     	if($GLOBALS['pagenow']=='user-new.php'){
    
    	  }elseif (empty($password_1)) {
    			$content['errors']->add('password_1',__('Password cannot be empty.', 'signup_password'));
    		}
    		else {
    			if ( !empty( $password_1 )  && $_POST['stage'] == 'validate-user-signup' ) {
    				if ( $password_1 != $password_2 ) {
    					$content['errors']->add('password_1', __('Passwords do not match.', 'signup_password'));
    				}
    			}
    		}
    
    	return $content;
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.