Skip Navigation

[Resolved] hide specific post according to the selected custom filed by user role B

This support ticket is created 5 years, 4 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
- 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 5 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#1322683

Tell us what you are trying to do?

I have corporate loan matching website project has two specific user role : company (loan applicants), BANK (Bank Managers)

- Company will upload their business profile and current loan status per bank via toolset form
- filed group 'bank' is repeatable filed
* bank (list selector filed)
* amount ( number filed)

in this case, is it possible to hide/restrict specific post for user role bank? when the user role company select AAA bank, a bank manager of AAA bank should not see the post. (BBB bank and CCC bank can see the post)

There will be one custom post type and post grid view. post show/hide should controlled by a single filed 'bank (list selector filed)'.

Please advice.

#1323087

Hi there,

Thank you for waiting, while I performed some tests.

To achieve what you're planning, here are the steps:

1. You can use the Toolset Access plugin, to register custom user roles for each bank, as explained in this guide:
https://toolset.com/documentation/user-guides/managing-wordpress-admin-capabilities-access/#creating-custom-roles

Example:

- Bank A
- Bank B
- Bank C

Note: in the database, the slugs of these user roles will be saved as "bank_a", "bank_b" & "bank_c" respectively.

2. This is how you can set the bank names and the slug values in the Bank select type custom field for your posts:
Screenshot: hidden link

Note: The "Display text" values can be anything, but the actual "Custom field content" values, should match the slugs of the bank user roles, from step 1.

3. In your post's view, you can include a query filter for this "Bank" custom field, so that it only shows those posts, where the values passed in shortcode parameter e.g. "excluderole" of the current user's role is different.
( ref: https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/ )
Screenshot: hidden link

4. To get the current user's role value, you can use the shortcode:
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-current-user )


[wpv-current-user info="role"]

5. As the last step, you'll update your post view's shortcode to include the shortcode parameter "excluderole":
( ref: https://toolset.com/documentation/user-guides/passing-arguments-to-views/ )


[wpv-view name="slug-of-the-view" excluderole="[wpv-current-user info='role']"]

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar