fix validate on metadata type User #354

This commit is contained in:
vnmedeiros 2020-04-21 11:21:32 -03:00
parent 4792abd70b
commit 9dd62bac6a
1 changed files with 4 additions and 4 deletions

View File

@ -53,16 +53,16 @@ class User extends Metadata_Type {
*/
public function validate(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
if ( is_array($values) ) {
foreach($values as $user) {
if ( is_array($value) ) {
foreach($value as $user) {
if ( !$this->user_exists($user) ) {
$this->add_error( sprintf(__('User does not exist %s.', 'tainacan'), $user ) );
$this->add_error( sprintf(__('User does not exist (ID: %s).', 'tainacan'), $user ) );
return false;
}
}
} else {
if ( !$this->user_exists($value) ) {
$this->add_error( sprintf( __('User does not exist %s.', 'tainacan'), $user ) );
$this->add_error( sprintf( __('User does not exist (ID: %s).', 'tainacan'), $value ) );
return false;
}
}