[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.
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?
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.
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:
==> 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