} $v1->run(); $v2->run(); if (sizeof($v1->errors) > 0 || sizeof($v2->errors)) { $error_course_add = $v1->getMessageErrors() . "<br/>"; $error_course_add .= $v2->getMessageErrors(); } else { $cats = array(); foreach ($v1->sanitized as $key => $value) { if (preg_match('/^[0-9]{1,}$/', $key) && isIdCategoryWpExist($value)) { $cats[] = $value; } } $users = array(); foreach ($v2->sanitized as $key => $authorId) { if (preg_match('/^[0-9]{1,}$/', $key) && StudyPressUserWP::exist($authorId)) { $users[] = $authorId; } } if ($cats) { if ($users) { $managerCourse->add(new Course(array('name' => $v1->sanitized['name'], 'description' => $v1->sanitized['desc'], 'pictureId' => isset($v1->sanitized['pictureId']) ? $v1->sanitized['pictureId'] : '', 'categories' => $cats, 'authors' => $users))); } else { $error_course_add = $tr->__("Please select at least one author"); } } else { $error_course_add = $tr->__("Please select at least one category"); } } } else { $error_course_add = $tr->__("Please select a category");