WP_REST_Posts_Controller::check_create_permission()
Checks if a post can be created.
Method of the class: WP_REST_Posts_Controller{}
No Hooks.
Return
true|false
. Whether the post can be created.
Usage
// protected - for code of main (parent) or child class $result = $this->check_create_permission( $post );
- $post(WP_Post) (required)
- Post object.
Changelog
Since 4.7.0 | Introduced. |
WP_REST_Posts_Controller::check_create_permission() WP REST Posts Controller::check create permission code WP 6.6.2
protected function check_create_permission( $post ) { $post_type = get_post_type_object( $post->post_type ); if ( ! $this->check_is_post_type_allowed( $post_type ) ) { return false; } return current_user_can( $post_type->cap->create_posts ); }