Created
March 20, 2024 14:02
-
-
Save andrewlimaza/2e8bfdf778ce0a2672de980063e068b2 to your computer and use it in GitHub Desktop.
Add approval status to members list of Paid Memberships Pro
This file contains 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 | |
/** | |
* Adds approval status column to the members list. | |
* | |
* @param [type] $columns | |
* @return void | |
*/ | |
function my_pmpro_add_memberslist_col_approval( $columns ) { | |
$columns['approval'] = 'Approval Status'; | |
return $columns; | |
} | |
add_filter( 'pmpro_manage_memberslist_columns', 'my_pmpro_add_memberslist_col_approval' ); | |
/** | |
* Fills the "Approval" column of the Members List. | |
* | |
* @param string $colname column being filled. | |
* @param string $user_id to get information for. | |
*/ | |
function my_pmpro_fill_memberslist_col_approval( $colname, $user_id ) { | |
$level = pmpro_getMembershipLevelForUser( $user_id ); | |
if ( 'approval' === $colname ) { | |
$approval_status = PMPro_Approvals::getUserApprovalStatus( $user_id, $level->id ); | |
if ( $approval_status !== NULL ) { | |
echo ucfirst( $approval_status ); | |
} else { | |
// Already existed before Approvals Add On (You can echo out any message here.) | |
} | |
} | |
} | |
add_filter( 'pmpro_manage_memberslist_custom_column', 'my_pmpro_fill_memberslist_col_approval', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment