[wp-trac] [WordPress Trac] #49345: User with admin privileges cannot edit some pages/posts

WordPress Trac noreply at wordpress.org
Sun Feb 2 20:05:30 UTC 2020


#49345: User with admin privileges cannot edit some pages/posts
-----------------------------+-----------------------------
 Reporter:  malamiao         |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Role/Capability  |    Version:  5.3.2
 Severity:  normal           |   Keywords:  needs-patch
  Focuses:                   |
-----------------------------+-----------------------------
 It happened to me when I deleted the admin user with ID = 1 and moved all
 its posts and pages to another user with admin privileges. As soon as I
 did it, some older pages could not be edited anymore (only seen or
 deleted).

 In order to regain control of those pages, I had to patch wp-
 includes/capabilities.php as follows:

 {{{
 function current_user_can( $capability, ...$args ) {
        $current_user = wp_get_current_user();

        if ( empty( $current_user ) ) {
                return false;
        }

        if ($current_user->has_cap(‘create_users')) return true; // line
 added

        return $current_user->has_cap( $capability, ...$args );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49345>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list