Skip to content

Instantly share code, notes, and snippets.

@cryptexvinci
Last active February 28, 2023 05:56
Show Gist options
  • Save cryptexvinci/6e4106fe2fe0f277b26c6342b6214722 to your computer and use it in GitHub Desktop.
Save cryptexvinci/6e4106fe2fe0f277b26c6342b6214722 to your computer and use it in GitHub Desktop.
Add a css class to Ultimate Member restricted content article div container.
<?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;
}
@danstramer
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment