Hi Toolset team,
i just want to setup limit of post type per user. I use this php code in function.php, which i found on your support forum and it works perfect. But I would like to add limit for another form into this php code, but im not able to setup this code :-/ could you help me with this? When i copied this code two times (and of course change name of form and id) it didnt work for me.
I need to add into this php code same function for another form - for example (name of form: cars, id of form: 299).
I know that for you guys it will take maybe just minute to setup.
add_filter('cred_form_validate','my_validation',10,2);
function my_validation($field_data, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$field_data;
//uncomment this if you want to print the field values
//print_r($fields);
//validate if specific form
if ($form_data['id']==288)
{
$user = get_current_user_id();
$user_post_count = count_user_posts( $user , 'article' );
$user_data = get_userdata($user);
$user_role = $user_data->roles;
if ( $user_role[0] == 'vendor' && $user_post_count > 3)
{
//set error message for my_field
$errors['wpcf-omezeni']='If you want more article contact us';
}
if ( $user_role[0] == 'premium' && $user_post_count > 999)
{
//set error message for my_field
$errors['wpcf-user-validation']='No limit';
}
//check if featured image exists
}
//return result
return array($fields,$errors);
}