Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created March 5, 2021 16:12
Show Gist options
  • Save nikitasinelnikov/2d8c1eae15e578fd424a18df9954d7ee to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/2d8c1eae15e578fd424a18df9954d7ee to your computer and use it in GitHub Desktop.
Ultimate Member: Make the user profile page restricted for not logged in users with restriction message
function um_custom_restriction_settings( $restriction, $post ) {
if ( ! is_user_logged_in() && um_is_core_post( $post, 'user' ) ) {
$restriction_meta = get_post_meta( $post->ID, 'um_content_restriction', true );
if ( $restriction_meta['_um_accessible'] == '2' && $restriction_meta['_um_noaccess_action'] == '0' ) {
$restriction = $restriction_meta;
}
}
return $restriction;
}
add_filter( 'um_post_content_restriction_settings', 'um_custom_restriction_settings', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment