chekc if user can delete a collection

This commit is contained in:
Jacson Passold 2018-01-08 19:53:10 -02:00
parent 2f1b9a3815
commit 3fc7bc00ba
1 changed files with 8 additions and 5 deletions

View File

@ -169,11 +169,14 @@ class Collections extends Repository {
* @return mixed|Collection
*/
public function delete($args){
if(!empty($args[1]) && $args[1]['is_permanently'] === true){
return new Entities\Collection(wp_delete_post($args[0], $args[1]['is_permanently']));
}
return new Entities\Collection(wp_trash_post($args[0]));
if($this->can_delete($args[0])) {
if(!empty($args[1]) && $args[1]['is_permanently'] === true){
return new Entities\Collection(wp_delete_post($args[0], $args[1]['is_permanently']));
}
return new Entities\Collection(wp_trash_post($args[0]));
}
throw new \Exception('This user can not delete the entity');
}
/**