Skip Navigation

[Resolved] Display _____ or placeholder if User Field submission is null

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'd like to display some User Fields embedded inside a paragraph, But is there a way to display a placeholder value instead (such as '_____' to indicate a blank).

Solution:

Yes, it is possible, you can use shortcode [wpv-conditional] to check if custom user field is empty, then display other content, for example:

https://toolset.com/forums/topic/display-_____-or-placeholder-if-user-field-submission-is-null/#post-1129564

Relevant Documentation:

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/#checking-for-the-current-user-data

This support ticket is created 6 years, 4 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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by GamX 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1129391
form settings.png
single line text field settings.png
radio field settings.png

Hi, I'd like to display some User Fields embedded inside a paragraph. I can get this to work beautifully.

But is there a way to display a placeholder value instead (such as '_____' to indicate a blank) in the case where:
1. The user has not yet selected a radio button choice ('1-1-sense-most') or
2. The user submits a blank text value in a single line field ('1-1-undesired-trait')?

CUSTOM USER FIELD SETTINGS
See screenshots.

USER FORM SETTINGS
See screenshot.

USER FORM CODE
[creduserform]
<div class="form-group">
<label>1-1-sense-most</label>
[cred_field field="1-1-sense-most" force_type="field" class="form-control" output="bootstrap"]
</div>
<div class="form-group">
<label>1-1-undesired-trait</label>
[cred_field field="1-1-undesired-trait" force_type="field" class="form-control" output="bootstrap"]
</div>
[cred_field field="form_submit" output="bootstrap" value="Submit" class="btn btn-primary btn-lg"]
[/creduserform]

USER FIELD DISPLAY SHORTCODES INSIDE A PARAGRAPH
You walk into a room. Immediately you [types usermeta='1-1-sense-most' current_user='true'][/types] something different than usual. Your [types usermeta='1-1-undesired-trait' current_user='true'][/types] coworker is sitting at the table waiting for you.

EXAMPLE OF PARAGRAPH IF VALUES ARE SUBMITTED:
You walk into a room. Immediately you see something different than usual. Your rude coworker is sitting at the table waiting for you.

WHAT I WANT TO SEE IF THERE ARE NO VALUES OR BLANKS SUBMITTED:
You walk into a room. Immediately you _____ something different than usual. Your _____ coworker is sitting at the table waiting for you.

#1129564

Hello,

Yes, it is possible, you can use shortcode [wpv-conditional] to check if custom user field is empty, then display other content, for example:

[wpv-conditional if="('[types usermeta='1-1-sense-most' current_user='true']' eq '')"]
_____
[/wpv-conditional]
[wpv-conditional if="('[types usermeta='1-1-sense-most' current_user='true']' nq '')"]
[types usermeta='1-1-sense-most' current_user='true']
[/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/#checking-for-the-current-user-data

#1130764

Hi, thanks for this... I did get it to work by using ne instead of nq.

Would the empty function be similar, or is that for a different purpose?

I'd also like to submit a feature request for adding an "else" statement so there can be less code. Thank you!

#1131652

There is a built-in attribute "evaluate" within shortcode [wpv-conditional], it can do the same thing as else statement:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional
attributes:
evaluate (opt):
true | false
It can be set to true or false and controls whether we want the condition to be met or not. The default value is true.

#1132266

My issue is resolved now. Thank you!