Skip Navigation

[Resolved] Logged in conditional statement not working

This thread is resolved. Here is a description of the problem and solution.

Problem:
Display a CRED Form to only logged in users using this code:

[wpv-conditional if="( '[wpv-current-user info='loggedin']' eq 'true' )" debug="true"]I am Logged in[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info='loggedin']' eq 'false' )" debug="true"]I am not Logged in[/wpv-conditional]

Solution:
The mistake was in the info='loggedin' and once we change it to info='logged_in' the condition works.

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]I am Logged in[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]I am not Logged in[/wpv-conditional]

Further, in this case there was some problem in the custom evaluation function that was added in the theme’s functions.php file that was breaking the conditional to work.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created 6 years, 10 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
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Amin 6 years, 10 months ago.

Assisted by: Noman.

Author
Posts
#535963
Capture.PNG

I am trying to: display a cred form to only logged in users using this code

  [wpv-conditional if="( '[wpv-current-user info='loggedin']' eq 'true' )" debug="true"]I am Logged in[/wpv-conditional]
  
[wpv-conditional if="( '[wpv-current-user info='loggedin']' eq 'false' )" debug="true"]I am not Logged in[/wpv-conditional]

I visited this URL: hidden link

I expected to see: logged in or logged out

Instead, I got: Nothing, It is not working. weird

#536044

Noman
Supporter

Languages: English (English )

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

Hi Amin,

Thank you for contacting Toolset support. I have just checked this same conditional output in a View, using CRED form at my end and it appears to be working. Looks like the mistake is in the info='loggedin' and once we change it to info='logged_in' the condition works.

- Can you please try the following code and see what happens?

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]I am Logged in[/wpv-conditional]
 [wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]I am not Logged in[/wpv-conditional]

- If it still does not work, please let us know that are you using this condition in the Content Template or View or a normal post / page?

Thank you

#536110

Hello

I am using this in a content template and again it didn't worked.
This CT is assigned to a view.

#536208

Noman
Supporter

Languages: English (English )

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

Hello Amin,

To debug this issue further, I will need to take a look at your setup. So I need to request temporary access (WP-Admin and FTP Login info) to your staging site.

Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

✙ Please add the Links to the [Content Template] Edit Screen [Page] Edit Screen where you have applied this Content Template.

Looking forward to help you, Thank you

#536266

I confirm that backup has been done and you have permission to activate and deactivate plugins.

#536289

Noman
Supporter

Languages: English (English )

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

Hello Amin,

I have debugged this issue and found that the problem is in the Child Theme in the function “function my_filter” and as such when I comment out this filter in functions.php file:

//add_filter('wpv-extra-condition-filters', 'my_filter');

==> And remove this custom evaluation from the View:

[wpv-if evaluate="urlevaluate"]
        <!-- wpv-loop-end -->
 [/wpv-if]
 [wpv-if condition="false" evaluate="urlevaluate"]
 
 [/wpv-if]

==> Then the conditional output works as normal. You can now check here:
hidden link

---------------------------------------------------------
I have created a test View with Content Template with same conditional and it is working as expected, please check this test page:
hidden link

Test View for Conditional output: hidden link

So as you can see that [wpv-current-user info='logged_in'] is itself working now, and there is something going wrong in the custom function / evaluation that you have created, please kindly check that one. Thank you

#536301

Thanks

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