Skip Navigation

[Resolved] Default cred_field value in cred form – Taxonomy

This support ticket is created 4 years, 8 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by sergeP 4 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1558973

Hello,

I have 2 different user roles (Artiste and Author) and both can create the same custom post type "song".
I have two different CRED Forms allowing users to create songs, one for the Artistes and the other for the Author.

I would like to be able to add a hidden taxonomy field in order to differenciate the posts"song" created by Author and the posts "song created by "artists".

Basically, I would like to add a hidden field like this but with a preselected value such as default="taxonomy-meta" :

 <div style="display: none;">
[cred_field field='taxonomy-slug' force_type='taxonomy' output='bootstrap' display='select' single_select='true']
   </div>

Is it possible ?

Thank you in advance for your help.

#1559533

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It's not possible to set a default taxonomy (note the description of the 'value' attribute of the cred_field shortcode which can be used to set default values: https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_field).

If it was a custom field you could set a default value.

But for a taxonomy you would need to use the API and apply the taxonomy term after the form was submitted and the post saved, i.e. use the cred_save_data hook: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

You could use that to apply a taxomomy to the new post (you have the post ID) depending on the role of the current user.

#1561545

My issue is resolved now. Thank you!