Skip to content

Instantly share code, notes, and snippets.

@cartpauj
Created June 13, 2023 14:07
Show Gist options
  • Save cartpauj/15a808ff34109617af7449cea4a89130 to your computer and use it in GitHub Desktop.
Save cartpauj/15a808ff34109617af7449cea4a89130 to your computer and use it in GitHub Desktop.
Bypass New User Approve if certain Membership(s) is purchased in MemberPress
<?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');
@cartpauj
Copy link
Author

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.

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