Skip Navigation

[Resolved] Conditional Statement with Custom User Field

This support ticket is created 4 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.

This topic contains 1 reply, has 1 voice.

Last updated by Darryl 4 years, 2 months ago.

Author
Posts
#1786525

I have a custom user field and I would like to compare the value from the current user with the post-id of the current post in a conditional statement.

[code]
[types usermeta='member-employer-connection' current_user='true'][/types] - [wpv-post-id]
[wpv-conditional if="( '[types usermeta='member-employer-connection' current_user='true'][/types]' eq '[wpv-post-id]' )"]
They are the same
[/wpv-conditional]
[/code]

The first line just shows the value of the custom user field for the current user and the current post's id so I can see if they're the same.

I based what I'm doing off a post by Minesh here: https://toolset.com/forums/topic/conditional-display-based-on-custom-user-field/
I have a user loop where I used Minesh's code to see if the user field was empty or not and that worked fine.

Now I want to see if the custom user field for the currently logged in user matches the post id of the currently viewed post.

#1786655

In my conditional statement, I had a form that my test user did not have access to. I changed the access on the form and it worked 🙂