Skip to content

Instantly share code, notes, and snippets.

@cartpauj
Last active April 13, 2020 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cartpauj/4fffc30dcd3edcf49a9063ca8deaa5dd to your computer and use it in GitHub Desktop.
Save cartpauj/4fffc30dcd3edcf49a9063ca8deaa5dd to your computer and use it in GitHub Desktop.
Auto Approve Sub Accounts - and a list of Memberships by ID
<?php
// allow for verification to be required for free trial users.
function mepr_newuser_approve_override($user_id) {
$auto_approve = array(970688, 970684, 970687, 970686, 970685); //An array of product ID's to auto approve
if(!class_exists('MeprOptions')) { return; }
if(!isset($_POST['mepr_product_id']) && !isset($_POST['manage_sub_accounts_form'])) { return $user_id; } //Not a MemberPress signup?
$product_id = isset($_POST['mepr_product_id'])?$_POST['mepr_product_id']:false;
if(isset($_POST['manage_sub_accounts_form']) || ($product_id && in_array($product_id, $auto_approve))) {
$_REQUEST['action'] = 'createuser';
}
}
add_filter('user_register', 'mepr_newuser_approve_override', 8);
@cartpauj
Copy link
Author

Edit the ID's in line #4 with the ID's of your Memberships that should be auto-approved.

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