Created
February 4, 2026 15:14
-
-
Save dwanjuki/560c15a193daf9f40af6a97cb4715718 to your computer and use it in GitHub Desktop.
Output Group Code, Group IDs, Group Parents and Parent Levels
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 // copy from below. | |
| /** | |
| * Get Group Accounts data. | |
| * | |
| * To run this script, visit yoursite.com/wp-admin/?pmpro_get_groups=1 | |
| * | |
| * 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 my_pmprogroupacct_get_groups_data() { | |
| if ( isset( $_REQUEST['pmpro_get_groups'] ) && class_exists( 'PMProGroupAcct_Group' ) ) { | |
| // Get all groups. | |
| $groups = PMProGroupAcct_Group::get_groups(); | |
| // Bail if no groups. | |
| if ( empty( $groups ) ) { | |
| exit( 'No Group Accounts found' ); | |
| } | |
| // Output table. | |
| echo '<table><tr><th>Group ID</th><th>Group Code</th><th>Group Parent</th><th>Group Parent Level ID</th><tr>'; | |
| foreach ( $groups as $group ) { | |
| $group_parent_user = get_user_by( 'ID', $group->group_parent_user_id ); | |
| $parent_user_info = empty( $group_parent_user ) ? esc_html( $group->group_parent_user_id ) : '<a href="' . esc_url( pmprogroupacct_member_edit_url_for_user( $group_parent_user ) ) . '">' . esc_html( $group_parent_user->user_login ) . '</a>'; | |
| echo '<tr><td>' . esc_html( $group->id ) . '</td><td>' . esc_html( $group->group_checkout_code ) . '</td><td>' . $parent_user_info . '</td><td>' . esc_html( $group->group_parent_level_id ) . '</td></tr>'; | |
| } | |
| echo '</table>'; | |
| exit(); | |
| } | |
| } | |
| add_action( 'admin_init', 'my_pmprogroupacct_get_groups_data' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment