Skip Navigation

[Resolved] Conditional 'Current user ID is equal to Author ID' not working

This support ticket is created 4 years, 1 month 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by shaunV 4 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1804879

I am trying to create a conditional that matches the Current logged in user ID with the post author ID, to create a post edit button. This conditional works with other post types, but does not seem to work with a specific CPT created by Toolset.

I have tried to use a block, and this short-code:
[wpv-conditional if=" ( ( '[wpv-current-user info="id"]' = '[wpv-post-author format="meta" meta="ID" ]' ) ) " debug="true"]you are the post author[/wpv-conditional]

The code above does not generate a debug information, but when I try to compare static values like '1 = 1', the debug does work.

I have tried deactivating multiple plug-ins but that has not created the desired conditional nor debug info.

#1804893

This does populate with the correct info:

[wpv-post-author format='meta' meta='id']
[wpv-current-user info='id']

#1804915

Shane
Supporter

Languages: English (English )

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

Hi Shaun,

Thank you for getting in touch.

Can you add your conditional like this below.

[wpv-conditional if=" ( ( '[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' ]' ) ) " debug="true"]you are the post author[/wpv-conditional]

I can see some missmatching with the quotations used. Please let me know if the above works now.

Thanks,
Shane

#1804931
Screen Shot 2020-10-08 at 3.28.27 PM.png
Screen Shot 2020-10-08 at 3.27.52 PM.png

Unfortunately it does not work on the front end nor provides debug info.

On the back-end it does provide the ID numbers, as you may see in one of the screenshots.

#1804951

Shane
Supporter

Languages: English (English )

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

Hi Shaun,

Would you mind providing me with admin access to the website so that I can have a look at this for you.

Also send me a link to the page where you are experiencing the issue.

Thanks,
Shane

#1804991

Shane
Supporter

Languages: English (English )

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

Hi Shaun,

Based on what i'm seeing there shouldn't be any reason for this conditional not to be working.

Would you mind if I grabbed a copy of your site to do some further testing locally?

Thanks,
Shane

#1804993

Yes, it's strange it is not working.

Please go ahead and grab a copy.

Thank you.

#1806399

Shane
Supporter

Languages: English (English )

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

Hi Shaun,

The issue seems to be coming from the content template itself.

Once I created a new content template and added the conditionals they started working without any issues at all.

Can you try doing this on your end and let me know if it works.

Create a completely new content template and start adding a few conditionals as a test.

Thanks,
Shane

#1806413

My issue is resolved now. The problem lies in the additional header I added, which has a few conditionals, once I remove it all debug works...
Thank you for helping me resolve it.