Skip Navigation

[Resolved] Cred Form Taxonomy default and choice

This support ticket is created 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Waqar 4 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#1705945

Tell us what you are trying to do?
I allow members to upload an embed video, I also allow them to choose from a variety of categories. but I also want each video to have an additional category ( Default:video ) one as well

Is there any documentation that you are following?
I have seen some but they do not really meet my requirements

Is there a similar example that we can see?
None that I know of

What is the link to your site?
hidden link

#1706257

Hi,

Thank you for contacting us and I'd be happy to assist.

To suggest the best way to achieve this, I'll need to see how this form and the category terms are set up in the admin area.

Can you please share temporary admin login details, along with a link to a page where this form can be seen?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1707743

Thank you for sharing the admin access.

During testing on my website with a similar form and taxonomy setup, I was able to make this work, using the "cred_save_data" hook:
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data )


add_action('cred_save_data','attach_default_tax_func',15,2);
function attach_default_tax_func($post_id, $form_data) {
	if ($form_data['id']==4544) {

		$target_term_ID = '128';
		$target_taxonomy = 'video-media-category';

		wp_set_post_terms( $post_id, $target_term_ID, $target_taxonomy, true );

	}
}

The above code snippet will make sure that the "video" term with ID "128" in the taxonomy "video-media-category" is also attached to the post created using the form "Video Submission" with ID "4544".

This snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

I hope this helps and please let me know if you need any further assistance around this.