[Resolved] Use Custom Select List To Save Post Category With CRED Form

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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Related documentation: Front-end Content Submission and Editing Forms

This topic contains 4 replies, has 2 voices, and was last updated by  PhantomPWR 1 week, 2 days ago. The support staff assigned to this topic is Christian Cox.

Viewing 5 posts - 1 through 5 (of 5 total)

I am trying to:

Use my own select dropdown(via a view inside the form) for selecting a category in the CRED post submission form.

I use a URL parameter (terms-filter=xyz), to filter only the categories I want in my select dropdown. The default CRED category select dropdown lists ALL the categories, which is not useful in my case.

Link to a page where the issue can be seen:


I expected to see:

The submitted post in my selected category in WP Admin -> Posts

Instead, I got:

The submitted post is saved under "Uncategorized"


Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-04:00)

Hi, you have a couple of JavaScript errors thrown on this page, and I'm not really able to troubleshoot effectively until those are resolved. Can you take a look? I've attached a screenshot here.

I use a URL parameter (terms-filter=xyz), to filter only the categories I want in my select dropdown.
Be careful here. You've got terms-filter used as a filter parameter in the category-parent View, but terms_filter used to define a default value in your CRED field shortcode.

[cred_field field='category' display='select' single_select='true' output='bootstrap' value='Select model' urlparam='terms_filter']

Looks like trouble to me, I would consider consolidating or using very different parameter names instead of two similar names.

//Create a dynamic category by the CRED form.
function func_cat_id($cat_id,$form_data) {
    if ($form_data['id']==6814) {
        $args = array('term_id' => $cat_id);

I'd like to point out 2 issues I noticed right away.

First, cat_id isn't going to be help you access a category term ID. It's going to be the ID of the post created by CRED. Please review the documentation for the cred_save_data hook:
The first parameter will always be the post_id, and you can't just change the variable name to get something else here.

Second, I think you should use wp_set_post_terms to manage terms, not wp_update_post:
You will have access to the post ID in the first callback function argument, and you can get other form selections from $_POST.

I'll be glad to go into more detail here, but I would need some more information from you about how you expect this to work. I'm not clear what you're trying to accomplish with the category parent and category select fields.


Hi Christian,

Thanks for getting back to me.

1. Javascript errors - sorted
2. urlparam="terms_filter" - changed to urlparam="terms-filter"

Just a quick explanation of what I'm trying to achieve - I'll use the current form, categories, etc as an example:

1. For this particular form, the category hierarchy is: Commercial(Aircraft Type) -> Airbus(Aircraft Manufacturer) -> A300-600(Aircraft Model), A300B4-200(Aircraft Model), A300B4-203(Aircraft Model), etc.

2. The "terms-filter=14" parameter in the URL, is the category id of the aircraft manufacturer(Airbus)

At the moment, the CRED category select dropdown, displays ALL available categories on the site. What I need, is to display the list of child categories(models) of the direct category parent(manufacturer: Airbus, id: 14).

When you click on "COMMERCIAL" in the menu, you'll see the list of manufacturers with their respective ids.

At the moment, you'll see two select dropdowns in the form. Both of them work halfway.

The first one is my own, which is generated by a parent/child view, which displays the correct categories(models), depending on the "terms-filter" URL parameter. Although the display is correct, the post is saved under "uncategorized".

The second dropdown select is the default CRED category dropdown, which saves the post in the correct category, but doesn't display the correct categories.

So, I either need a way for my selected category to be "recognised" by the form OR I need to be able to tell the CRED dropdown to only show the relevant (child)categories.

Does this make sense?

I'd really appreciate your help and/or advice! 🙂


Christian Cox
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/New_York (GMT-04:00)

Okay I think it's working correctly now, please confirm. I submitted several tests and set them to "Draft" status - feel free to delete them. Here is what I did:
- Modified your functions.php file:

//Create a dynamic category by the CRED form.
function func_save_cat_id_for_cred_post($post_id,$form_data) {
    if ($form_data['id']==6814) {
        wp_set_post_terms( $post_id, $_POST['category'], 'category', false );

If you store local copies of this file, be sure to download this update.

- Deleted the 2nd, standard CRED category field

- Modified the child View's Loop Output to use name="category" on the select field:

<select id="d1cc" class="model-select-list" name="category" data-wpt-type="select">
      <option>- Select a model -</option>
			<option value="[wpv-taxonomy-id]" data-wpt-name="category" data-wpt-type="option">[wpv-taxonomy-title]</option>

Hi Christian,

You are a hero!

I can confirm that the form now works perfectly.

Thanks a million and have an awesome day! 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Known issues and their solutions

We document known issues and their solutions in Toolset erratas. Save time by checking there first and seeing if what you are facing is a known issue. This list is kept short. We do our best to resolve all known issues with every release of Toolset plugins.

Support Policy

Toolset staff will help you use the Toolset plugins correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

For more information, read our full Customer Support Policy.

Need custom programming work for your site? Check out our certified partners.