Skip to content

Instantly share code, notes, and snippets.

@cartpauj
Last active March 23, 2020 14:24
Show Gist options
  • Save cartpauj/9fa8dff5065a7b720463 to your computer and use it in GitHub Desktop.
Save cartpauj/9fa8dff5065a7b720463 to your computer and use it in GitHub Desktop.
Unset the password fields errors from MemberPress and auto-generate the user pass instead
<?php
//This file only unsets the errors
//You'll still need to override the app/views/checkout/form.php file to remove the password fields HTML
//You can find instructions on overriding template files here: https://www.memberpress.com/1.1.7
function unset_password_validation_errors($errors) {
if(empty($errors)) { return $errors; } //Should never happen if the password fields are hidden
//Unset the password field errors
// IF YOU'VE TRANSLATED THE PLUGIN - YOU MAY NEED TO CHANGE THESE ENGLISH TEXTS TO YOUR LANGUAGE
foreach($errors as $i => $v) {
if($v == 'You must enter a Password.') {
unset($errors[$i]);
}
if($v == 'You must enter a Password Confirmation.') {
unset($errors[$i]);
}
if(stripslashes($v) == "Your Password and Password Confirmation don't match.") {
unset($errors[$i]);
}
}
//Artificially set a password here
$_POST['mepr_user_password'] = uniqid(); //Deprecated?
$_REQUEST['mepr_user_password'] = uniqid();
return $errors;
}
add_filter('mepr-validate-signup', 'unset_password_validation_errors');
@cartpauj
Copy link
Author

UPDATE: MP Has since created a setting to "Hide password fields" so this code is really no longer necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment