I made this shortcode:
function give_shortcode() {
return do_shortcode('[types usermeta="online-giving-form-embed-code" output="raw" user_name="[wpv-search-term param=church]"[/types]');
}
add_shortcode('give', 'give_shortcode');
Then I use this shortcode in my condition:
[wpv-conditional if="( '[give]' eq '' )"] I am empty [/wpv-conditional]
This means if the GIVE field is not filled out for this user, then it shows "I am empty". This DOES work.
However, if I use
[wpv-conditional if="( '[give]' ne '' )"] I am NOT empty [/wpv-conditional]
This does NOT work and doesn't show this message on items where the give field is filled in.
What am I doing wrong? What would be the proper code to use to only show something if the field is filled in? It only seems to work for those items where it is empty.
That seems like the right syntax, so I suspect something else is going on. Can you turn on debug?
[wpv-conditional if="( '[give]' ne '' )" debug="true"] I am NOT empty [/wpv-conditional]
Then reload the front-end of the site and tell me what the debug information shows.
This is all that appears on the page that IS empty:
I am empty
####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' ne '' )
[debug] => true
)
####################
Debug information
####################
--------------------
Original expression: ( '' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ( '' ne '' )
Comparing to
The page that isn't empty doesn't show anything.
Okay first be sure you have registered give in Toolset > Settings > Front-end Content > Third party shortcode arguments. Next, copy the "give" shortcode and paste it outside the conditionals so I can see what it produces:
Give: [give]<br />
[wpv-conditional if="( '[give]' ne '' )" debug="true"] I am NOT empty [/wpv-conditional]
Ya know what... even if I put in a value to GIVE and go to this page, it still shows that 'i am empty' code. So something deeper is going on.
Okay sorry about that. Had to tweak it so the 'empty' really does work. So here is the code that works for EMPTY:
[wpv-conditional if="( '[types usermeta='online-giving-form-embed-code' user_name='[wpv-search-term param=church]' output='raw'][/types]' eq '' )"]
I am empty
[/wpv-conditional]
If I put NE instead of EQ, it doesn't work still.
Copy the code from the conditional and place it just before the conditional so we can inspect it:
User meta info: [types usermeta='online-giving-form-embed-code' user_name='[wpv-search-term param=church]' output='raw'][/types]<br />
[wpv-conditional if="( '[types usermeta='online-giving-form-embed-code' user_name='[wpv-search-term param=church]' output='raw'][/types]' ne '' )"]
I am NOT empty
[/wpv-conditional]
I think I may have gotten it working... I'll keep you updated.
Okay I narrowed it down. So this is what I have in my field as data
<script src="<em><u>hidden link</u></em>"></script>
Apparently toolset doesn't view that as something but it also doesn't view it as nothing. Can you help so that if I have a script code in there, it specifically views it as NOT EMPTY for the conditional statements?
You could store the URL of the script src in the custom field instead and then build the script tag from that using a custom shortcode. That would get around the problem of not being able to test a script using a conditional.
It might not always be a script though, is the problem. Sometimes it will be something else. Is there another way toolset can see it as raw text so it sees that field as filled in?
What type of field is this?
It is a multiline field. Is there a different one that would work?
The wysiwyg field doesnt work either, so what do I do? It's not just <script> code that toolset conditionals don't see. It's ALL html code. Can you provide a workaround or a fix? This is pretty important.
It's not just <script> code that toolset conditionals don't see. It's ALL html code.
If you place <div></div> in a WYSIWYG field, it will correctly register not empty. The script tag is the only one that's a problem here. It's a security risk, so there are some precautions built into the system that strip those tags out in some cases. Let me ask my 2nd tier team if there's a better way to handle this. I'll let you know what I find out.