| | 29 | $ptype = get_post_type_object( $post_data['post_type'] ); |
| | 30 | |
| | 31 | if ( $update && ! current_user_can( $ptype->cap->edit_post, $post_data['ID'] ) ) { |
| | 32 | if ( 'page' == $post_data['post_type'] ) |
| | 33 | return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
| | 34 | else |
| | 35 | return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
| | 36 | } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
| | 37 | if ( 'page' == $post_data['post_type'] ) |
| | 38 | return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
| | 39 | else |
| | 40 | return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
| | 41 | } |
| | 42 | |
| 54 | | $ptype = get_post_type_object( $post_data['post_type'] ); |
| 55 | | if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) { |
| 56 | | if ( $update ) { |
| 57 | | if ( ! current_user_can( $ptype->cap->edit_post, $post_data['ID'] ) ) { |
| 58 | | if ( 'page' == $post_data['post_type'] ) { |
| 59 | | return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
| 60 | | } else { |
| 61 | | return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
| 62 | | } |
| 63 | | } |
| 64 | | } else { |
| 65 | | if ( ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
| 66 | | if ( 'page' == $post_data['post_type'] ) { |
| 67 | | return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
| 68 | | } else { |
| 69 | | return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
| 70 | | } |
| 71 | | } |
| 72 | | } |
| | 68 | if ( ! $update && isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
| | 69 | && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
| | 70 | |
| | 71 | if ( 'page' == $post_data['post_type'] ) |
| | 72 | return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
| | 73 | else |
| | 74 | return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |