Skip to main content
updated code
Source Link
tfrommen
  • 9.2k
  • 7
  • 40
  • 59

You can get_post(), check if the get_current_user_id equals the post_author information, and then act upon that...

$post_idif =('edit.php' YOUR-ID-HERE;=== $GLOBALS['pagenow']) {  if (   current_user_can('administrator')   || get_post($post_idfilter_input(INPUT_POST, 'post_id'))->post_author == get_current_user_id()  ) {   // Yes, you can } else { wp_redirect(admin_url()); exit; } } 

You can get_post(), check if the get_current_user_id equals the post_author information, and then act upon that...

$post_id = YOUR-ID-HERE; if ( current_user_can('administrator') || get_post($post_id)->post_author == get_current_user_id() ) { // Yes, you can } 

You can get_post(), check if the get_current_user_id equals the post_author information, and then act upon that...

if ('edit.php' === $GLOBALS['pagenow']) {  if (   current_user_can('administrator')   || get_post(filter_input(INPUT_POST, 'post_id'))->post_author == get_current_user_id()  ) {   // Yes, you can } else { wp_redirect(admin_url()); exit; } } 
Source Link
tfrommen
  • 9.2k
  • 7
  • 40
  • 59

You can get_post(), check if the get_current_user_id equals the post_author information, and then act upon that...

$post_id = YOUR-ID-HERE; if ( current_user_can('administrator') || get_post($post_id)->post_author == get_current_user_id() ) { // Yes, you can }