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.
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
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!
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.
My issue is resolved now. Thank you!