Last active
March 30, 2021 18:19
-
-
Save gausam/0a926a802ee6cd3b98b957d28a7a7486 to your computer and use it in GitHub Desktop.
List an account's sponsored members on the Membership Account page.
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 | |
/** | |
* This recipe lists an account's sponsored members on the Membership Account page. | |
* | |
* It is intended for use with the Sponsord Members Add On: | |
* https://www.paidmembershipspro.com/add-ons/pmpro-sponsored-members/ | |
* | |
* 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 mypmpro_member_action_links_after() { | |
global $current_user; | |
$user_ids = pmprosm_getChildren( $current_user->ID ); | |
if ( ! empty( $user_ids ) ) { | |
?> | |
<br/><br/> | |
<h3>Sponsored Members</h3> | |
<table class="pmpro_table" width="100%" cellpadding="0" cellspacing="0" border="0"> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Email</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php | |
$user_list = new WP_User_Query( array( | |
'include' => $user_ids, | |
'orderby' => 'name', | |
'order' => 'ASC' | |
) ); | |
$sponsored_members = $user_list->get_results(); | |
if ( ! empty( $sponsored_members ) ) { | |
foreach( $sponsored_members as $sponsored_member ) { | |
echo '<tr><td>' . esc_html($sponsored_member->data->display_name ) . | |
'</td><td> ' . esc_html( $sponsored_member->data->user_email ) . | |
' </td></tr>'; | |
} | |
} | |
?> | |
</tbody> | |
</table> | |
<?php | |
} | |
} | |
add_action( 'pmpro_member_action_links_after', 'mypmpro_member_action_links_after' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment