Last active
March 30, 2026 16:32
-
-
Save greenhornet79/5c37ac1c4ad4a1968f655467865a3bcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // this requires an edu email address to sign up for the level. Can be changed to whatever the requirements are. | |
| // front end check | |
| add_filter('leaky_paywall_account_setup_validation', function ($errors, $fields) { | |
| $edu_level_id = '6'; | |
| if (isset($fields['level_id']) && $edu_level_id === $fields['level_id']) { | |
| $email = isset($fields['email_address']) ? $fields['email_address'] : ''; | |
| $domain = substr(strrchr($email, '@'), 1); | |
| if (! $domain || substr(strtolower($domain), -4) !== '.edu') { | |
| $errors['edu_email'] = array( | |
| 'message' => __('This subscription level requires a .edu email address.', 'leaky-paywall'), | |
| ); | |
| } | |
| } | |
| return $errors; | |
| }, 10, 2); | |
| // server side check for redundancy | |
| add_filter( 'leaky_paywall_registration_form_errors', function( $errors, $fields ) { | |
| $edu_level_id = '5'; | |
| if ( isset( $fields['level_id'] ) && $edu_level_id === $fields['level_id'] ) { | |
| $email = isset( $fields['email'] ) ? $fields['email'] : ''; | |
| $domain = substr( strrchr( $email, '@' ), 1 ); | |
| if ( ! $domain || substr( strtolower( $domain ), -4 ) !== '.edu' ) { | |
| $errors[] = 'This subscription level requires a .edu email address.'; | |
| } | |
| } | |
| return $errors; | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment