Skip Navigation

[Résolu] Conditional Statement with Custom User Field

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

This topic contains 1 réponse, has 1 voix.

Last updated by Darryl Il y a 3 années et 6 mois.

Auteur
Publications
#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 🙂

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