Created
February 16, 2023 18:02
-
-
Save JarrydLong/25f64c3a25d20a8f8c0b75bae5355b31 to your computer and use it in GitHub Desktop.
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 //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