Last active
February 28, 2023 05:56
-
-
Save cryptexvinci/6e4106fe2fe0f277b26c6342b6214722 to your computer and use it in GitHub Desktop.
Add a css class to Ultimate Member restricted content article div container.
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 | |
add_filter( 'post_class', 'um_add_restricted_class_css', 10, 1 ); | |
function um_add_restricted_class_css($classes){ | |
global $post; | |
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true ); | |
// if the post is restricted do this. | |
if ( $restriction['_um_accessible'] == 2 ){ | |
$classes[] = 'um-restricted-content'; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. Do you know of an option to add a class which will signify if the user is allowed to view the content or not?
Something like: 'um-restricted-content-allowed' for a user who is allowed to view the content.