Skip Navigation

[Resolved] What is the recommended way to control access to views

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Author
Posts
#1287537

I have a view that should only be visible to logged in users (menu item controlled by nav_menu and the users of a specific role can display the filtered view. At the moment if any the user (or not even logged in) enters the url of the view page, the view displays.

I have added posts and pages to access control.

I can't find a document that provides recommends a way to control the access to pages that contains views.

Regards

#1287553

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

If you just wanted to check user is logged in or not. You can check it using [wpv-conditional] shortcode. Please try to use following code:

[wpv-conditional if="('[wpv-current-user info='id']' ne  '')"]
 User is logged in - add your view here
[/wpv-conditional]

[wpv-conditional if="('[wpv-current-user info='id']' ed  '')"]
 User is NOT logged in
[/wpv-conditional]

Please have look at the following documentation that may help you:
=> https://toolset.com/documentation/views-shortcodes/#wpv-current-user
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Please check this related ticket where I shared more solution related to current user role:
=> https://toolset.com/forums/topic/author-page-depending-on-the-role-of-the-user/#post-538421

#1287631

Thanks for the information but my question was
What is the recommended way to control access to views?
This is with an assumption of using Toolset Access to control who can see the view.

#1287649

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When you say who can see the view? do you mean on backend or frontend?

#1287655

On the front end.
I have made changes to Toolset Access to limit the who can see the post type that the view is based on, but it does not seem to stop the view being seen by anybody.
I could find specific documentation on how to control the access to a view so it is only visible to a role on the front end.
On the page in question
I have enabled elementor pro for editing and have 1 view.

#1287657

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you want to display the view role-based - as I already shared the solution here:
=> https://toolset.com/forums/topic/author-page-depending-on-the-role-of-the-user/#post-538421

you can use Toolset Access shortcode [toolset_access] shortcode.

For example:

[toolset_access role="customer" operator="allow"]
Add your view here - this view will be visible to role=customer only
[/toolset_access]

Where:
- you can change the original role name with customer

More info:
=> https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

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