CRED plugin provides an API, making it easy to customize your post or user forms. The API includes hooks (actions and filters) to accomplish specific tasks using PHP code.
When you ask for help or report issues, make sure to tell us all related information about your form and what you want to achieve.
Viewing 15 topics - 361 through 375 (of 453 total)
Problem: I have a Form that edits posts, which includes a custom field. I would like to automatically set a taxonomy term on the post when the Form is submitted. The term should be determined by the value of the custom field.
Solution: Use the function wp_set_object_terms to set a term on a post:
Instead of term-slug you can use:
A single term slug, single term id, or array of either term slugs or ids. This will replace all existing related terms in this taxonomy. Passing an empty value will remove all related terms.
The last parameter false will delete all the other category terms from this post. If you use true instead of false, the existing category terms will not be deleted.
I have a CRED form with three select fields. If select field A has a certain value, select field C should change it's value through custom code. The custom code works fine. The only problem, that I am facing is, that I don't know, how I should apply the if condition with the CRED select field.
Solution:
It is a custom PHP codes problem, see the solution here:
Problem:
The user would like to change a user role using a Toolset form.
Solution:
Because WordPress allows a user to have multiple roles, this requires custom code to remove the existing role for the user and add the new role.
Check this sample code:
add_action('cred_save_data', 'cred_update_user_role_pending',10,2);
function cred_update_user_role_pending($post_id, $form_data) {
if ($form_data['id'] == 3386 ) {
$user = new WP_User( $post_id );
$user->remove_role('pendingtechnician');
$user->add_role('technician');
}
}