Skip Navigation

[Resolved] Also hide previews by POSTS GROUPS

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by a.R 7 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#465532

a.R

I can hide posts controlled by POSTS GROUPS, but

how can I also hide the posts preview in
- VIEWS and
- MENUS?

It is not nice to see a post preview in a widget or menu and then, after clicking on it, being told the post doesn´t exist.
So it would be good if ANY TRACE of a post the user doesn´t have access to would disappear.

Can you help me here?

THANK YOU, kind regards.

#465701

Dear A.R,

I assume we are talking about "Access control for field groups":
https://toolset.com/documentation/user-guides/access-control-for-user-fields/

Yes, it is expected result, views will be able to output the posts which are setup as hidden in "Access control for field groups" settings, as a workaround you can add a filter in your view:
Display only the posts do not have any "Post Group" setting.

For example, add below codes in your theme/functions.php:

add_filter( 'wpv_filter_query', 'non_access_posts_func', 10, 3 );
function non_access_posts_func( $query, $view_settings, $views_id ) {
	if ( $views_id == 123 ) {
		$query['meta_query'][] = array(
			'key'     => '_wpcf_access_group',
			'compare' => 'NOT EXISTS',
		);
    }
    return $query;
}

Please replace 123 with your Views ID

#465743

a.R

Hi,

I do not understand, what that has to do with filed groups, but it seems to help for VIEWS.

However, is there also a solution to hide posts with POST GROUP SETTING from MENUS?

Thank, you, kind regards

#465759

It depends on how do you setup the menu, and I suggest you setup a content template with Views shortcode [wpv-login-form]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-login-form

And display above content template when current user does not have access to the post:
https://toolset.com/documentation/user-guides/access-control-for-user-fields/

#466972

a.R

Ok, thank you.

I would like to hide certain posts from the wordpress primary menu, depending from their toolset-post-group.
(Right now, I´m using the plugin "add descendants as submenu items".)

Is that possible?

#467268

You will need to find the codes in the plugin "add descendants as submenu items", which if for querying the posts, and add codes as I mentioned above:
https://toolset.com/forums/topic/also-hide-previews-by-posts-groups/#post-465701

More help:
https://codex.wordpress.org/Class_Reference/WP_Query

#467352

a.R

Ok, I will try to do that.

If I can´t, maybe I will use another plugin to auto hide certain posts from menus.
Can you maybe recommend me one?

Thank you, kind regards.

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.