• As I understand it, by default, the Contributor role is allowed to create and edit posts, but can’t publish them (nor edit published posts). However, in my install, Contributors do not have the Post icon showing, and so have no way to create a post.

    I previously used the User Roles Editor plugin, but deactivated and deleted it. Still, I suspect it corrupted the role somehow. However, when I look in the wp_options table, wp_user_roles shows the Contributor role as having edit_posts and create_posts enabled.

    How can I correct this issue? Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Well, sometimes toggles in databases are a little odd about their meanings. Not that this is the case but…

    Why don’t you try reinstalling and enabling the User Role Editor you had before then use that to set your contributor users with the roles you want them to have?

    You can then disable it again and delete it if you wish to keep it from affecting other user roles… I’d be a little slow on the trigger with that this time around just in case I needed it again… thus the disable recommendation for now.

    Thread Starter jamminjames

    (@jamminjames)

    Thanks for the suggestion. However, I did that — no change. Contributors still have no access to posts.

    Also, I tried another plugin, “Members – Membership & User Role Editor,” and the funny thing is, both show Contributors as having the ability to create & edit posts. But even after saving, no change.

    • This reply was modified 4 years, 4 months ago by jamminjames.
    Thread Starter jamminjames

    (@jamminjames)

    Okay, did the ol’ deactivate plugins and reactivate one at a time trick, and voila, found a conflicting plugin: WP User Avatar. Or it could possibly be a function I have in the child theme relating to that plugin.

    Guess I should’ve done that first. Thanks for your help anyway!

    Thread Starter jamminjames

    (@jamminjames)

    Unfortunately, the plugin changed hands a few months ago, and it appears the new owners are not responding to support requests in the forum. So, I’m leaving this thread unresolved, in hopes someone can help.

    Upon further investigation, I found the culprit within the plugin. It’s the wp_user_avatar settings “allow upload” option. When this is checked, Contributors no longer have access to posts. In fact, in the wp_options table in the WordPress database, if the value for option_name “wp_user_avatar_allow_upload” is “1” (true), the post access vanishes for Contributors. Changing that to “0” (false) restores access.

    In the plugin’s file, “includes/class-wp-user-avatar-subscriber.php”, there’s this snippet:

      public function wpua_subscriber_capability() {
        global $blog_id, $wpdb, $wpua_allow_upload, $wpua_edit_avatar;
        $wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
        $user_roles = get_option($wp_user_roles);
        if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1) {
          $user_roles['subscriber']['capabilities']['edit_posts'] = true;
        } else {
         if(isset($user_roles['subscriber']['capabilities']['edit_posts'])){
         	unset($user_roles['subscriber']['capabilities']['edit_posts']);
         }
        }
        update_option($wp_user_roles, $user_roles);
      }

    I tried adding lines for $user_roles['contributor'], but that had no effect. I also tried commenting this section out altogether, but still, when that plugin option is checked, same result. For now, I’m leaving that option unchecked (false), but it’s nice for users to be able to upload their own avatar via this plugin.

    So, not sure how to resolve this problem programmatically. Any suggestions?

    • This reply was modified 4 years, 4 months ago by jamminjames. Reason: added code found in plugin
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Contributor role can’t create post’ is closed to new replies.