How to conditionally display or hide content in a View based on user meta?

By: Julius hernández | Asked: 10/28/2021
ForumsCategory: How-toHow to conditionally display or hide content in a View based on user meta?
Julius hernándezJulius hernández asked 3 years ago
I need to display columns in a grid, based on current user meta. Think of it as if there are several price fields and I need that certain users only see a given column. The user meta field is user_prices_view, and the values can be "regular price", "sale price" or "customer price". The admins set any value they need to any user. Now, if when a View is shown for a user with "regular price" in meta, that user only sees the column with price A field; user with "sale price" only sees column with price B field, and obviously user with "customer price" only sees column with price C field. In the View code I tried with something like: [if current_user_meta="sale price"][sale_price][/if current_user_meta] [if current_user_id show="user_prices_view" equals="sale price"][sale_price][/if current_user_meta] ...with no success. The problem is there are no built-in conditionals to check user_meta values (set with Formidable Registration add-on). Some ideas?
Kuba S replied 3 years ago

I use this plugin for such stuff. https://www.role-editor.com/
It looks outdated but is extremely useful and does the job.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right