|
@@ 5025-5036 (lines=12) @@
|
| 5022 |
|
|
| 5023 |
|
// If an author id was provided then use it instead. |
| 5024 |
|
if ( isset( $content_struct['wp_author_id'] ) && ( $user->ID != $content_struct['wp_author_id'] ) ) { |
| 5025 |
|
switch ( $post_type ) { |
| 5026 |
|
case "post": |
| 5027 |
|
if ( !current_user_can( 'edit_others_posts' ) ) |
| 5028 |
|
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
| 5029 |
|
break; |
| 5030 |
|
case "page": |
| 5031 |
|
if ( !current_user_can( 'edit_others_pages' ) ) |
| 5032 |
|
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
| 5033 |
|
break; |
| 5034 |
|
default: |
| 5035 |
|
return new IXR_Error( 401, __( 'Invalid post type.' ) ); |
| 5036 |
|
} |
| 5037 |
|
$author = get_userdata( $content_struct['wp_author_id'] ); |
| 5038 |
|
if ( ! $author ) |
| 5039 |
|
return new IXR_Error( 404, __( 'Invalid author ID.' ) ); |
|
@@ 5365-5378 (lines=14) @@
|
| 5362 |
|
if ( isset( $content_struct['wp_author_id'] ) ) { |
| 5363 |
|
// Check permissions if attempting to switch author to or from another user. |
| 5364 |
|
if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) { |
| 5365 |
|
switch ( $post_type ) { |
| 5366 |
|
case 'post': |
| 5367 |
|
if ( ! current_user_can( 'edit_others_posts' ) ) { |
| 5368 |
|
return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) ); |
| 5369 |
|
} |
| 5370 |
|
break; |
| 5371 |
|
case 'page': |
| 5372 |
|
if ( ! current_user_can( 'edit_others_pages' ) ) { |
| 5373 |
|
return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) ); |
| 5374 |
|
} |
| 5375 |
|
break; |
| 5376 |
|
default: |
| 5377 |
|
return new IXR_Error( 401, __( 'Invalid post type.' ) ); |
| 5378 |
|
} |
| 5379 |
|
$post_author = $content_struct['wp_author_id']; |
| 5380 |
|
} |
| 5381 |
|
} |