Skip Navigation

[Resolved] Conditional Block – check for form submittal using either: null or ''

This support ticket is created 2 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

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

This topic contains 7 replies, has 2 voices.

Last updated by GamX 2 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#2045111

Hello, I'm using Conditional Blocks in the advanced editor to check for whether the user has submitted a user form or not. As per previous Toolset guidance, I was using these search parameters:

To show content if user has not yet submitted a form: ( '[wpv-search-term param="_success"]' eq '' )
To show content if user has submitted a form: ( '[wpv-search-term param="_success"]' ne '' )

This worked when I was using Toolset Views, but since I upgraded to Toolset Blocks, I get an error message in the RH column under where it gives a summary of the conditions specified in the editor:

If I use either of the above statements, I get this error message: "Incomplete condition"

In spite of this error, on the user end the view is as expected. But because my condition isn't listed in the summary, it's hard to troubleshoot without going into every single block to check my code.

HOWEVER...
If I instead use this statement:
( '[wpv-search-term param="_success"]' eq null )
I get this message: "Search term is equal to null."

Or if I use this statement:
( '[wpv-search-term param="_success"]' ne null )
I get this message: "Search term is not equal to null."

Because I just randomly tried this without knowing if it was a correct approach, can you please confirm that this approach is okay for use in the Advanced Editor? I don't want to run into any other problems.

Thanks!

#2045899

Waqar
Supporter

Languages: English (English )

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

Hi,

Thank you for contacting us and I'd be happy to assist.

To add conditional checks based on the value of a URL parameter '_success', I'll recommend using these expressions:

To check if the value is empty:


( empty( '[wpv-search-term param="_success"]') ) 

To check if the value is not empty:


( NOT(empty( '[wpv-search-term param="_success"]')) ) 

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2047021

Hi thanks for the reply... the first statement above seems to work:
( empty( '[wpv-search-term param="_success"]') )

However, when I plug in the second statement into the conditional block's advanced editor and click the "Accept" button, it strips out the "NOT" so instead of this:
( NOT(empty( '[wpv-search-term param="_success"]')) )

It converts itself to this after I click "Accept":
( empty( '[wpv-search-term param="_success"]') )

#2051327

Waqar
Supporter

Languages: English (English )

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

Thanks for writing back.

You can slightly update the conditional check for the 'not empty' case so that the 'NOT' is outside the brackets:


NOT( (empty( '[wpv-search-term param="_success"]')) ) 

This should do the trick.

#2051923

Hi... I tried the revised NOT statement...
NOT( (empty( '[wpv-search-term param="_success"]')) )

...but when I click the "Accept" button in the Advanced Editor, now I get the following error message (in the yellow highlighted area above the code):
"Please, complete all the conditions or remove them."

#2051945

Hello, after more testing, the revised NOT statement is now yielding the same effects as before.

This is now the only content in the Advanced Editor of the Conditional Block:
NOT( (empty( '[wpv-search-term param="_success"]')) )

But when I click the "Accept" button, it changes the statement to this:
( empty( '[wpv-search-term param="_success"]') )

Ideally I want to combine other conditions using AND/OR with this empty or not empty condition, but I need to get this simple statement working first. Grateful for any help to resolve this!

#2052771

Waqar
Supporter

Languages: English (English )

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

I've tested these conditions again, but could't reproduce this behaviour, as can be seen in this screencast:
hidden link

I'm sharing the exact conditional statements that I've used in my tests:

Empty:


  ( empty( '[wpv-search-term   param="_success"]') ) 

Not Empty:


 NOT ( empty( '[wpv-search-term   param="_success"]') ) 

In case the issue still persists, you're welcome to share temporary admin login details, along with the link to an example page with these conditional blocks.

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

#2054373

SUMMARY of what works and what doesn't, including submission of a specific form (ID 3100)

Each of these conditional statements works as expected:
( empty( '[wpv-search-term param="_success"]') )
( empty( '[wpv-search-term param="_success"]') AND ( '[types usermeta="1-1-user-field" output="raw" current_user="true"][/types]' eq '1' ) )
( ( '[wpv-search-term param="_success"]' eq '3100_1' ) )
NOT ( empty( '[wpv-search-term param="_success"]') )
( NOT ( empty( '[wpv-search-term param="_success"]') ) )
( ( NOT ( empty( '[wpv-search-term param="_success"]') ) ) AND ( '[types usermeta="1-1-user-field" output="raw" current_user="true"][/types]' eq '1' ) )
( NOT ( empty( '[wpv-search-term param="_success"]') ) AND ( '[types usermeta="1-1-user-field" output="raw" current_user="true"][/types]' eq '1' ) )

In Advanced Editor, the following result in an error in yellow highlighted area: “Please, complete all the conditions or remove them":
( NOT(empty( '[wpv-search-term param="_success"]’) ) )
NOT( (empty( '[wpv-search-term param="_success"]’) ) )
( '[wpv-search-term param="_success"]' = ‘3100_1’ )

Renders as expected on front end, but when conditional block is selected in the Gutenberg Block Editor, the note in RH column says: “incomplete condition”:
( ( '[wpv-search-term param="_success"]' eq '' ) )
( ( '[wpv-search-term param="_success"]' ne '' ) )

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