Tagged: masonry
-
AuthorPosts
-
June 17, 2020 at 1:23 pm #1223368
Hi There!
I hope you guys can help me out with this one!
Im using the plugin “Restrict Content Pro” and there is a function: Hide Restricted Posts – Check this to hide all restricted posts from queries when the user does not have access. But it does’t hide…
– The posts still show up, and get directed to the register page. Is there a way to actually NOT show these posts at al for users without access?
or
– Is there a possibility for the Masonry to actually not show a category (or post) if the user does not have access?
or
– Or another way around it to add categories to the masonry if the user has the right access level or levels?
i was trying this, but didn’t manage to figure it out…add_filter(‘avia_masonry_entries_query’, ‘avia_masonry_custom_query’);
function avia_masonry_custom_query( $query ) {
$subscription_id = rcp_get_subscription_id( get_current_user_id() );
//number is restrict membership level ID
if (( $subscription_id == 1 ) === false) {
//number is post > category ID
$exclude_cat = array(‘category__not_in’ => array( 71 ) ) ;
$query = array_merge((array)$exclude_cat, (array)$query);
}
//number is restrict membership level ID
elseif (( $subscription_id == 2 ) === false) {
//number is post > category ID
$exclude_cat = array(‘category__not_in’ => array( 74 ) ) ;
$query = array_merge((array)$exclude_cat, (array)$query);
}
return $query;
}Much Thanks!
June 22, 2020 at 4:03 am #1224462Hey Rhodo,
Sorry for the late reply and thanks for the link, I see that some of your masonry items have the classesrcp-is-restricted rcp-no-access
, so with the plugin identifying which items to hide we can use this css:.rcp-is-restricted.rcp-no-access { display: none; }
Now you want to show these items to some users, so lets add the user role to the body as a class,
Try adding this code to the end of your functions.php file in Appearance > Editor:function add_role_to_body($classes) { global $current_user; $user_role = $current_user->roles; return array_merge( $classes, array( $user_role[0] ) ); } add_filter('body_class','add_role_to_body');
So now you can choose which user type can see the content via css classes, such as
administrator
like this:.rcp-is-restricted.rcp-no-access { display: none; } #top.administrator .rcp-is-restricted.rcp-no-access { display: block; }
Please try this css in the General Styling > Quick CSS field or in the WordPress > Customize > Additional CSS field
After applying the css, Please clear your browser cache and check.Best regards,
MikeJune 30, 2020 at 8:30 pm #1226905I managed to just css it idd like you suggested, Thank you so much, rcp did not even take time to point me in the right direction.
Also per page i added code with the block to show specific css to restricted users that did the trick![restrict subscription=2]
<style> My CSS for the page </style>
[/restrict]—
Warm RegardsJune 30, 2020 at 9:12 pm #1226911Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘HIDE Restricted Posts (RCP)’ is closed to new replies.