Created
October 20, 2015 15:58
-
-
Save messica/b60bffab6db97a4f0d8c to your computer and use it in GitHub Desktop.
Generate invite codes for all users with a certain membership level.
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 | |
| /* | |
| * Generate invite codes for all users with a certain membership level. | |
| */ | |
| function my_init() { | |
| if ( ! empty( $_REQUEST['create_invites'] ) && current_user_can( 'manage_options' ) ) { | |
| global $wpdb; | |
| // change level here | |
| $level_id = 1; | |
| // get all users with specific membership level | |
| $sql = "SELECT user_id FROM $wpdb->pmpro_memberships_users WHERE membership_id=" . $level_id . " AND status='active'"; | |
| $users = $wpdb->get_col($sql); | |
| // create codes for them | |
| foreach($users as $user_id) | |
| pmproio_createInviteCodes($user_id); | |
| } | |
| } | |
| add_filter( 'init', 'my_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment