Skip Navigation

[Resolved] How to show conditional info on CRED form based on data in generic field?

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

Problem:

Check if there is any project posts created by current logged-in user.

Solution:

I suggest you create a post view, for example:

https://toolset.com/forums/topic/how-to-show-conditional-info-on-cred-form-based-on-data-in-generic-field/#post-2304679

Relevant Documentation:

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 2 replies, has 2 voices.

Last updated by himanshuS 2 years ago.

Assisted by: Luo Yang.

Author
Posts
#2304585

Hey there,

I am using a generic field generated using comma-separated data. When there is no data in the field, I would like to show a message to the user that there is no data in the field.

For that, I was thinking of adding a conditional statement in the CRED form that checks if comma-separated values exist or not. If it is empty, it would like to show - 'You have not submitted a project. Please submit a project before requesting an endorsement'.

<div class="form-group project-submission-form-group">
		<label>[cred_i18n name='project-submission-label']Select Project Submission(s) (use command or ctrl key to select more than one project)[/cred_i18n]<span class="red-color">*</span></label>
       [cred_generic_field type='multiselect' field='project-submission']
	 {
	 "required":1,
	 "options":[ [xyz-ics snippet="Dynamic-list-of-project-submissions-by-current-user-not-part-of-group-submission"] ]
      }
	 [/cred_generic_field]
 </div>

Form view - hidden link

#2304679

Hello,

I assume we are talking about the custom shortcode you mentioned above:
[xyz-ics snippet="Dynamic-list-of-project-submissions-by-current-user-not-part-of-group-submission"]

There isn't such kind of built-in feature within Toolset plugins.

I suggest you create a post view:
- Query project posts
- Filter by post author is same as logged in user:
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/
- If there isn't any result found, display the message:
You have not submitted a project. Please submit a project before requesting an endorsement
- If there is any result found, display post form you mentioned above.

#2305127

My issue is resolved now. Thank you!

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