Created
June 13, 2023 14:07
-
-
Save cartpauj/15a808ff34109617af7449cea4a89130 to your computer and use it in GitHub Desktop.
Bypass New User Approve if certain Membership(s) is purchased in MemberPress
This file contains 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 | |
function nua_allow_user_if_membership($errors) { | |
$allowed_memberships = array(123,321,789,987); // CHANGE THIS | |
if(!is_user_logged_in()) { | |
if(in_array((int)$_POST['mepr_product_id'], $allowed_memberships)) { | |
$_REQUEST['action'] = 'createuser'; //Set this so "New User Approve" plugin will not limit the subscriber | |
} | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'nua_allow_user_if_membership'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can be pasted into a plugin like Code Snippets (run everywhere type snippet).
Edit line #2 and change the comma-separated list of ID's to the Membership ID's from MemberPress that you wish to allow new users to bypass approval on.
You can get a MemberPress membership ID by visiting the MemberPress > Memberships page in your wordpress dashboard and the ID's should be listed in the far-left column.