Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JarrydLong/25f64c3a25d20a8f8c0b75bae5355b31 to your computer and use it in GitHub Desktop.
Save JarrydLong/25f64c3a25d20a8f8c0b75bae5355b31 to your computer and use it in GitHub Desktop.
<?php //do not copy
/**
* This recipe adds the pmpro_pending_approval class to the pmpro_content_message
* element if the current user is pending approval.
*
* 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_approval_class( $class, $element ) {
if( $element === 'pmpro_content_message' ) {
if ( is_user_logged_in() ) {
if ( class_exists( 'PMPro_Approvals' ) ) {
global $current_user;
$approval_levels = PMPro_Approvals::getApprovalLevels();
foreach ( $approval_levels as $level ) {
if ( ! PMPro_Approvals::isApproved( $current_user->ID, $level ) ) {
$class[] = 'pmpro_pending_approval';
break;
}
}
}
};
}
return $class;
}
add_filter( 'pmpro_element_class', 'mypmpro_approval_class', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment