Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Admin, but… not admin? Confusing and annoying user roles problem.

Discussion in 'Misc WordPress Requests' started by AAv Soft, Dec 13, 2017.

  1. AAv Soft

    Guest

    Admin, but… not admin? Confusing and annoying user roles problem., by AAv Soft

    Hello there! My first post here.
    I have the “sorry, you are not allowed to edit this post” problem…
    I Googled around and I found A LOT of possible fixes. But NONE of them worked.

    When I try to add a new post, I get this error:
    Sorry, you are not allowed to edit this post.
    So I did the following:

    1. Deactivated all the plugins.

    2. Switching to the default theme.

    3. I used User Role Editor to set the capabilities for the Administrator role.
    The create_pages and create_posts permissions wasn’t checked. But I checked them, and still the same problem. Also, if I go to User Role Editor, in the “Select Role and change its capabilities:” combo box, the “Administrator” is not shown.

    4. I set define('WP_DEBUG', true); in …/public_html/wp-config.php. Now I see A LOT of errors. After I try to add a post, it says:


    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-admin/includes/post.php on line 198
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-admin/includes/post.php on line 199

    And in …/public_html/wp-admin/includes/post.php at those lines, I see this:

    Line 198: $post_data['post_type'] = $post->post_type;
    Line 199: $post_data['post_mime_type'] = $post->post_mime_type;

    5. In …/public_html/wp-includes/capabilities.php in this function:

    function current_user_can( $capability ) {
    $current_user = wp_get_current_user();

    if ( empty( $current_user ) )
    return false;

    $args = array_slice( func_get_args(), 1 );
    $args = array_merge( array( $capability ), $args );

    return call_user_func_array( array( $current_user, 'has_cap' ), $args );
    }

    I added (after “if(empty($current_user)) return false;“) this:

    if (is_admin())
    return true;

    After this, if I add a page, I don’t see the error but nothing happens.

    6. I looked around in MySql tables with phpMyAdmin at wp_usermeta and wp_users for some errors/corruptions. But it looks fine.
    Also in wp_options in the wp_user_roles column.

    Now, with the WP_DEBUG set to TRUE, when I go to Add Page, I get this errors:


    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 5966
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 5967
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 5971
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 6190
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/theme.php on line 2862
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/theme.php on line 3086
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 4069
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 4069
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-includes/post.php on line 3570
    Notice: Trying to get property of non-object in /home/cinemasa/public_html/wp-admin/includes/post.php on line 610
    Warning: Creating default object from empty value in /home/cinemasa/public_html/wp-admin/includes/post.php on line 642
    Notice: Undefined property: stdClass::$ID in /home/cinemasa/public_html/wp-admin/post-new.php on line 71
    Notice: Undefined property: stdClass::$post_date in /home/cinemasa/public_html/wp-admin/edit-form-advanced.php on line 144
    Notice: Undefined property: stdClass::$post_status in /home/cinemasa/public_html/wp-admin/edit-form-advanced.php on line 196
    Notice: Undefined property: stdClass::$post_status in /home/cinemasa/public_html/wp-admin/edit-form-advanced.php on line 230
    Notice: Undefined property: stdClass::$post_type in /home/cinemasa/public_html/wp-includes/taxonomy.php on line 202
    Notice: Undefined property: stdClass::$post_type in /home/cinemasa/public_html/wp-includes/taxonomy.php on line 204

    Please, PLEASE, help me out!

    Admin, but… not admin? Confusing and annoying user roles problem.
     
    #1

Share This Page

Monarch Social Sharing Plugin