Tell us what you are trying to do?
I am trying to display a "middle name" field if related "first name" field is 3 or fewer characters. e.g., if first name is "A.", show the middle name "John" with a space after, then show the last name field containing "Smith". If the first name field is "Dave", skip the middle name and space, then show last name field containing "Jones".
And i tried "lt '3'" for the conditional but of course that didn't work either.
I could probably fake it and do >= '.' to catch all the first names with periods in them, but of course there are exceptions to this that would make it impractical.
What is the link to your site? hidden link - This is an example of a page which requires the middle name field added. hidden link - This page would not need the middle name field. hidden link - An example that shows why checking for a period in first name would produce a false positive and add an unnecessary space ("V.L." here is contained entirely in the first name field, middle name field was left blank.)
Does this require custom code to first do the count? Or is there a way of writing the conditional that I'm not picking up out of the documentation?
Hello. Thank you for contacting the Toolset support.
Well - There is no native feature available to use REGEX with the conditional statement but what you should do is try to create custom shortcode OR function and pass your field value to it, validate your REGEX and pass boolean value true or false and use that custom shortcode or function with [wpv-conditional] shortcode.
Is there an example I could reference for doing the shortcode or function? I think I'm a little out of my depth. (I know just enough regex to use it in notepad++ and such. I'm very much a copy/paste/adjust level of coder.)
The only thing I found in the forums that's even kind of like what I'm trying to do is here: https://toolset.com/forums/topic/character-count-counting-up-cred-and-types-fields/
But that's javascript and related to adding a character count to a form field rather than getting a character count on a database item. So I guess...... not really what I'm trying to do at all!
I tried doing some searching but I only got as far as being pretty sure I need strlen.
So it's going to be something like a function that checks if strlen of first name is less than three then true, if not then false?
And then doing the conditional to check for true, and if yes, then print middle name.
The only thing I found in the forums that's even kind of like what I'm trying to do is here: https://toolset.com/forums/topic/character-count-counting-up-cred-and-types-fields/
But that's javascript and related to adding a character count to a form field rather than getting a character count on a database item. So I guess...... not really what I'm trying to do at all!
==> The above solution is to display the total number of characters within the Toolset form field.