Skip Navigation

[Resolved] Conditional tags with user meta

This support ticket is created 5 years, 5 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Shane 5 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1308241

Hi Toolset support,

I would like to build a privacy page for my users. I would like to give users a way to hide certain user meta fields for specific user roles. Lets say we have roles A, B and C and a custom user field 'e-mail'.

I created a user field called Privacy e-mail with option A, B, C (roles). I think it would be nice if a user can select which roles may NOT see this field. Role A is a quest (not logged in). B is an employee and C is an Agency. Let's say the user only wants to show the e-mail field to agencies. They can select option A and B so the field only shows up on users with an Agency role.

What's the best way to do this?

Thanks, Menno

#1308271

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Menno,

Thank you for contacting our support forum.

The best way to do this is by using a conditional shortcode with checkboxes, Not the checkbox group.

So you have a checkbox that says Show to Agency and another for Show to employee.

Then you can setup a conditional around the email display.

Using the conditional shortcodes below for your logic.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-types-fields-and-custom-fields/

Please try this and let me know if it helps.
Thanks,
Shane

#1308329

Hi Shane,

Thanks for your fast response. The point is that i needs to be on field basis.

So i have a field profile picture and e-mail for example. Both need 3 options: Show to guest, Show to Employee, Show to Employer.

My idea was this: a privacy custom field for every user field, with 3 checkboxes (guest, employee, employer).

Then a conditional: if logged in user has role employee AND user meta 'privacy-profile-picture' = true { don't show field }. Something like this :). It needs to check the role and privacy field.. I would like to use php for this.

Thanks,
Menno

#1308339

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Menno,

You may not need to use PHP for this because you can use our conditional shortcode for this as well.

You can use this shortcode here to get the current user role
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153354

There is also a way for you to combine your conditionals with an AND or an OR.

Take a look here
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/#connecting-conditions

Please let me know if this helps.
Thanks,
Shane