Skip Navigation

[Résolu] Condition if user not login and custom field value is 1

This support ticket is created Il y a 2 années et 5 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 7 réponses, has 3 voix.

Last updated by Waqar Il y a 2 années et 4 mois.

Assisted by: Waqar.

Auteur
Publications
#2224039
Screenshot 2021-11-18 at 8.28.48 PM.png

Dear Sir/Madam,

How can I configure the condition if user not login and custom field value is 1? I try attached screenshot but not work.

Best regards,

Kelvin.

#2224107
Screenshot 2021-11-18 at 10.26.12 PM.png
Screenshot 2021-11-18 at 10.19.51 PM.png
Screenshot 2021-11-18 at 10.19.15 PM.png

I tried to put

( $(competition-open-to-apply) eq '1' ) AND ( '[wpv-current-user info="logged_in"]' eq 'true' ) ) 

in the Edit conditions box, after I save it, it return

  ( ( '[wpv-post-field name="competition-open-to-apply" ]' eq '1' ) AND ( '[wpv-current-user info="id"]' eq 'true' ) ) 

but Conditions shows Incomplete condition

Could you should me what the correct condition rule I should put.

#2224157

Shane
Supporter

Languages: Anglais (English )

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

Hi Kelvin,

Based on what I see your conditionals should produce the correct results, however I would test the conditions individually before combining them.

For instance test to see if the condition for you user logged in check is working. This means that you will setup the conditional and add some content to the block then checking on the frontend if the conditional works when you've logged out.

I've tested the instance on my end to display some content if the user is logged out using the [wpv-current-user info="logged_in"] shortcode and it works fine.

I would suggest starting here as well as to enable the debug option on the conditional block to check what the conditional block is evaluating. However the debug information will only show up for admin users.

Please let me know the results of these checks and if further advice is required.

Thanks,
Shane

#2225565
Screenshot 2021-11-20 at 11.06.12 PM.png
Screenshot 2021-11-20 at 11.11.08 PM.png
Screenshot 2021-11-20 at 11.13.50 PM.png
Screenshot 2021-11-20 at 11.13.39 PM.png

Dear Shane,

I tried put

( '[wpv-current-user info="logged_in"]' eq 'true' )

but it reset to

  ( ( '[wpv-current-user info="id"]' eq 'true' ) ) 

What the correct expression should be?

I enable the debug on but how can I view the debug log?

Every Times when I edit the content template, I got log of error message before showing me the editor page. I did update all Toolset plugins to latest version and also the WP version.

#2226965

Shane
Supporter

Languages: Anglais (English )

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

Hi Kelvin,

Based on my test then the code below should work.
<codE>
( '[wpv-current-user info="logged_in"]' eq 'true' )
[/php]

Would you mind allowing me to have admin access to the website so that I can take a look at this for you ?

Please also send the page where the conditional is being used.

Thanks,
Shane

#2232183

Waqar
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

conditional-statement-example.png

Hi Kelvin,

Thank you for sharing the admin access.

Shane is on vacation, so I'll be following up on this ticket.

An important point to note, is that whenever we need to get the value from a Toolset Types custom field in conditional display evaluations using the '$' sign, the prefix 'wpcf-' should be used before the field slug.
( ref: https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/ )

In my tests, this conditional statement works:


  ( empty( '[wpv-current-user info="id"]') AND ( $(wpcf-competition-open-to-apply) eq '1' ) ) 

The attached screenshot shows, how the same statement can be created using the visual mode.

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

regards,
Waqar

#2232489
Screenshot 2021-11-29 at 10.57.54 PM.png
Screenshot 2021-11-29 at 10.54.03 PM.png

Dear Waqar,

I can't replicate your test, if I simply change the condition like

 ( $(wpcf-competition-open-to-apply) eq '1' ) 

I can see the button but I can't see it when using Incognito window if condition is

( empty( '[wpv-current-user info="id"]') AND ( $(wpcf-competition-open-to-apply) eq '1' ) ) 
#2232923

Waqar
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

I've noticed that all your conditional blocks in the template are placed inside the 'Reusable blocks'.

The nesting of conditional blocks inside the reusable blocks is not supported, so you'll have to include them outside your reusable blocks.

You can submit a feature request for this at:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

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