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 - 661 through 675 (of 709 total)
Problem: I would like to add some custom validation to a Form with two custom date fields. I would like to validate it such that the start date is before the end date. How can I access the date value in the $error_fields parameter?
Solution: Use the following syntax to access the Unix timestamp for a datepicker field:
add_filter('cred_form_validate','start_end_date',10,2);
function start_end_date($error_fields, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$error_fields;
...
$fields['wpcf-date-start']['value']['datepicker']
Update the custom code to work with the latest software versions:
add_filter('cred_success_redirect', 'stegvis_skjema_el_test',10,3);
function stegvis_skjema_el_test($url, $post_id, $form_data)
{
if ($form_data['id']==874)
{
$arr = array('content-template-id'=>925); //the step 2 CRED form template ID
$url = add_query_arg($arr, $url);
}
return $url;
}
If your site uses Layouts, you should create an unassigned Template Layout instead of an unassigned Content Template. Then the code should include the layout ID, not the content template ID, and the proper URL parameter.
add_filter('cred_success_redirect', 'stegvis_skjema_el_test',10,3);
function stegvis_skjema_el_test($url, $post_id, $form_data)
{
if ($form_data['id']==874)
{
$arr = array('layout_id'=>12345); //the step 2 CRED form template ID
$url = add_query_arg($arr, $url);
}
return $url;
}