Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/d20c5fc7f4e79204691e5827bf0a28c7 to your computer and use it in GitHub Desktop.
Save kimwhite/d20c5fc7f4e79204691e5827bf0a28c7 to your computer and use it in GitHub Desktop.
Importing from CSV. make sure Approved members show up on directory
<?php
/**
* Make sure approved users are active whenever you run an import using the Import Users From CSV Integration for Paid Memberships Pro.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function set_imported_user_to_pending( $user_id ) {
if ( ! class_exists( 'PMPro_Approvals' ) ) {
return;
}
$users_level = pmpro_getMembershipLevelForUser( $user_id );
// If their level doesn't require approval, just bail.
if ( ! empty( $users_level ) && ! PMPro_Approvals::requiresApproval( $users_level->id ) ) {
return;
}
// Set them to approved.
PMPro_Approvals::ApproveMember( $user_id, $users_level->id );
}
add_action( 'is_iu_post_user_import', 'set_imported_user_to_pending', 50, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment