Hi,
I have this code to restrict posts based on roles. This code works well: users with any other than "pro" role can create only one post with the cred form. If "pro" you can create two posts.
Ok, now I want to add another role, "pro-two", that can also have the 2 posts. Would you please help me (without PHP skills) how I add the "pro-two" have the similar priviledges than "pro". Thank you.
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;
//validate if specific form
if ($form_data['id']==559)
{
$user = get_current_user_id();
$user_post_count = count_user_posts( $user , 'pro' );
$user_data = get_userdata($user);
$user_role = $user_data->roles;
if ( $user_role[0] == 'subscriber' && $user_post_count > 0)
{
//set error message for my_field
$errors['wpcf-user-validation']='Only one post possible';
}
if ( $user_role[0] == 'pro' && $user_post_count > 1)
{
//set error message for my_field
$errors['wpcf-user-validation']='Two posts possible.';
}
}
//return result
return array($fields,$errors);
}