Getting custom plugin or code snippet to fire.
-
I have club members listed in the Participants Database plugin. Members must be in the database and membership must be active before they can register (using User Registration and Membership). I have written the following code and tested it both as a plugin and code snippet. According to error logging (which for easier reading purposes I have removed from the code below), the code is not executing. What am not understanding?
Thanks.
//Verify Email Active
/* Only active members located in Participants Database can register with the website.
* 1) Sanitize email
* 2) Find row in Participants Database containing sanitized email.
* 3) If row exists, check that membership status is active.
* 4) If row does not exist or membership status is not active, return error.
*/
function verify_custom_db_email_active ($errors, $sanitized_user_login, $user_email) {
global $wpdb;
$sanitized_email = sanitize_email($user_email);
$table = $wpdb->vxj2_participants_database;
// Query for the email
$row = $wpdb->get_row(
$wpdb->prepare ("SELECT membership_status FROM $table WHERE email = %s", $sanitized_email)
);
if ($row) { // Check if membership is active
if ($row->membership !== “Active”) {
$errors->add ('membership_inactive', __('Your membership is not active.'));
}
} else { // Email not found in database
$errors->add('email_not_found', __('Email address not found in our membership database.'));
}
return $errors;
}
add_filter ('registration_errors', 'verify_custom_db_email_active', 1, 3);
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Getting custom plugin or code snippet to fire.’ is closed to new replies.