Skip Navigation

[Resolved] Conditional Output for user

This support ticket is created 3 years, 2 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)

This topic contains 4 replies, has 3 voices.

Last updated by camila 3 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2170441

Hello,
In my website
hidden link
Login: develop
Pass: June2021
I have Upcoming Tax Sales that shows in 2 columns, first column is "Featured" and it should show all the tax sales that have not content restrictions. The second column is "Member" and it should show all the tax sales that are for members only.
Right because I am using the following code if a user is logged in can see the 2 columns and if it's logged out can only see it as "Featured". I want to show the 2 columns all the time even if user is logged in or not, and then restrict the url only.

this is the code:
[wpv-conditional if="( $(um_content_restriction) ne '1' )"]
<h3 class="green">Featured Property</h3>
<div class="view-4-container">
<h4>[wpv-view name="municipality-title-in-tax-sale-without-county"]</h4>
[wpv-view name="municipality-title-in-tax-sale"]
[wpv-view name="geo-area-in-tax-sale"]
<p style="padding-bottom:0;"><b>Tax Sale Date:</b> [types field="tax-sale-date"][/types] </p>
[wpv-view name="total-of-properties-from-a-tax-sale"]
[types field="reference"][/types]
<p class="icon"><i class="fas fa-star"></p></div>
[/wpv-conditional]
[wpv-conditional if="( $(um_content_restriction) eq '1' )"]
<h3>Members Only</h3>
<div class="view-4-container">
<h4>[wpv-view name="municipality-title-in-tax-sale-without-county"]</h4>
[wpv-view name="municipality-title-in-tax-sale"]
[wpv-view name="geo-area-in-tax-sale"]
<p style="padding-bottom:0;"><b>Tax Sale Date:</b> [types field="tax-sale-date"][/types] </p>
[wpv-view name="total-of-properties-from-a-tax-sale"]
[types field="reference"][/types]
<p class="icon"><i class="fas fa-users"></p>
</div>
[/wpv-conditional]

So my idea is to always show the content, only to show different content depending on the user role, i do not want that content to be hidden.

Please let me know if this makes sense

Thanks

#2170645

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Your question makes it sound as if this "works", except when logged out the right column is entirely missing and you want the column to be shown but its content to be hidden.

But from your description, it also sounds like the left column content should always be visible, whether users are logged in or not, while in the right column, perhaps you want to display a log-in link to logged-out users but the restricted content to logged-in users, would that be right?

Also, I'm not sure about your conditional shortcodes that check the custom field um_content_restriction. In the context you have used them, that means checking whether the page where you have added this markup itself has a value for the um_content_restriction custom field.

Is that what you intend?

This seemingly comes from some 3rd-party plugin I'm not familiar with, but I would imagine that you have individual posts that are marked as private or public using that custom field, no?

In which case you would make a View to display the public content (by adding a Query Filter that checks if that custom field is not 1), and a different View to display the private content (by adding a Query Filter to check if that custom field is 1).

Then you would only use the conditional shortcode to check if users were logged in or not, and you would have a structure something like this:

<div class="left-column">
  <!-- public content for all users -->
</div>
<div class="right-column">
  [wpv-conditional if="( '[wpv-current-user info='logged_in']' ne 'true' )"]
  <!-- link to login form -->
  [/wpv-conditional]
  [wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
  <!-- restricted content for logged-in users -->
  [/wpv-conditional]
</div>
#2171037

That almost works, but I am also showing different kinds of content for each column, that is why I am using the um_content_restriction. I need a way to check for the um_content_restrition of the post in the loop and if it's not user restricted show on the left column and if it's user restricted show on the right. so I will have different posts in each column

#2171149

Shane
Supporter

Languages: English (English )

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

Hi Camila,

I need a way to check for the um_content_restrition of the post in the loop and if it's not user restricted show on the left column and if it's user restricted show on the right. so I will have different posts in each column

I'm assuming here that you want to check each post individually that is listed on the page for the um_content_restriction value. In this case you will need to check the value in the view itself inside the <wpv-loop></wpv-loop>

In this you can essential curate which posts should be displayed in the view loop for logged out users. An alternative is to create a separate view that will just display those posts that are available for the logged out users.

Using Nigel's setup above you can essentially add that view to the section for logged out users.

Thanks,
Shane

#2172249

I had to go another way to make this work. thanks