Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created July 14, 2024 08:19
Show Gist options
  • Select an option

  • Save ipokkel/f4dd33342587feacd7acc4a759b53bd4 to your computer and use it in GitHub Desktop.

Select an option

Save ipokkel/f4dd33342587feacd7acc4a759b53bd4 to your computer and use it in GitHub Desktop.
<?php
/**
* Customize the registration error message.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function custom_registration_error_message( $errors, $sanitized_user_login, $user_email ) {
if ( isset( $errors->errors['username_exists'] ) ) {
$errors->errors['username_exists'][0] = 'This username is already in use. If you have an account, please log in to renew your membership.';
}
if ( isset( $errors->errors['email_exists'] ) ) {
$errors->errors['email_exists'][0] = 'This email is already in use. If you have an account, please log in to renew your membership.';
}
return $errors;
}
add_filter( 'registration_errors', 'custom_registration_error_message', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment