Good afternoon. On the local site I try to realize the possibility of selecting certain categories based on the value of another arbitrary field.
I came across a very interesting and detailed topic on the forum - https://toolset.com/forums/topic/restrict-user-to-select-one-category-only/page/2/.
With the help of these instructions I was able to output the categories I needed for the selection.
However, in message No. 550910 of that topic (https://toolset.com/forums/topic/restrict-user-to-select-one-category-only/page/2/#post-550910), Christian does not specify the actions , Which allow you to save the entry in the desired category. (- Added cred_save_data function to functions.php).
Help me correctly compose this function so that posts are stored in the desired category.
Dear Alex,
According to our support policy
https://toolset.com/toolset-support-policy/
You are asking a question about action hook "cred_save_data " of CRED plugin, could you provide a valid "Subscription" for the CRED plugin?
For your question:
Help me correctly compose this function so that posts are stored in the desired category.
It needs custom PHP codes, here are my suggest you try this:
1) when user submit the CRED form, use action "cred_save_data" to trigger a custom PHP function,
2) get the value of category, and save it into database with wordpress function wp_set_object_terms()