WordPress.org

Ready to get started?Download WordPress

Forums

Members
[resolved] user level field not updated (8 posts)

  1. Steve Taylor
    Member
    Posted 2 years ago #

    A small possible bug in an otherwise flawless plugin...

    Looking at how the "Author" drop-down on the post edit screen is populated, it seems, when you dig down, to depend on the wp_user_level field in the wp_usermeta table being greater than 0. I tried editing a custom role, defined using Members, to include level_1, but the users in that role didn't appear in the drop-down. Their wp_user_level field only updated when I changed their role (then changed it back again).

    I'm using this line to keep levels:

    remove_filter( 'members_get_capabilities', 'members_remove_old_levels' );

    I'm not sure if this has anything to do with the issue.

  2. jmanriquez68
    Member
    Posted 2 years ago #

    Steve,
    From what I can tell in your note, I think I might have a related issue.

    You understand more than I do but what is happening to me is that as administrator for some reason I can only see other administrators as authors. I would like to see other levels so I can change authors to posts.

    Specifically I have parent users, teacher users and admins. I want to see the teachers. I'm running the Member plugin to restrict access for posts and using s2Member.

    Given that you seem to understand what is happening, is there anything you can offer for help in how to do it?

    Thanks.

  3. zyrq
    Member
    Posted 2 years ago #

    @Steve Taylor,

    When I changed the wp_user_level >0 in the db the users did indeed show up. Good catch! Although user levels are deprecated, maybe they still should be used here...

    wp_dropdown_users allows only authors to be shown, see here:
    user-does-not-appear-in-post_author_override-drop-down-list

    See the next link for a workaround for showing the missing users:
    http://wordpress.org/support/topic/users-missing-from-author-dropdown-after-upgrade

    What exactly does your remove_filter do?

  4. Steve Taylor
    Member
    Posted 2 years ago #

    @jmanriquez68 and @zyrq, looks like there's more information here:

    http://wordpress.org/support/topic/author-changes-whenever-i-edit-a-post?replies=5

    Check the plugin's readme.html for details on this line, which should be added to your theme's functions.php:

    remove_filter( 'members_get_capabilities', 'members_remove_old_levels' );

    Basically this means that Members has a filter, members_remove_old_levels, which is in place by default, and when the members_get_capabilities filters are run, it steps in and removes the old-style numeric user levels. The above line removes that filter - which means the user levels aren't removed. You can see the difference when you edit a role - when the above line is in place, you'll see level_0, level_1, etc.

    What you need to do to get a role in the Author drop-down is give it level_1. Then you need to edit the user profiles with that role. As the post I've linked to above says, it looks like you just have to edit, save, no changes needed. I thought you had to change the role to something else then back again. Anyway, this is really what I thought was a small problem with the plugin. When you edit a role, the changes should be effective immediately without having to go and edit and save every user with that role (which could be quite a task on some installations!). Maybe the plugin needs to refresh the wp_user_level field in the wp_usermeta table when a role is edited?

  5. zyrq
    Member
    Posted 2 years ago #

    Maybe I just add the roles and caps in code.

    add_role('whatever', 'Whatever', array(
    'read' => 1,
    'level_0' => 1, //The level_n capabilities exist for backward compatibility*
    'cap1' => 1,
    'cap2' => 1,
    'and so on' => 1,
    ));

    *Beginning WP3

    in the code comments capabilities.php, there's this nice one:
    Get rid of levels since these are mostly useless in newer versions of WordPress. I would stress mostly.

    Anyway, the filter works, thanks.

  6. Justin Tadlock
    Member
    Plugin Author

    Posted 2 years ago #

    The problem you all are experiencing is due to a WordPress bug. If you want to see it fixed, you need to help get some attention of a core dev on this bug report:
    http://core.trac.wordpress.org/ticket/16841

    User levels were deprecated a few years ago in WordPress and replaced by capabilities. The reason the members_remove_old_levels filter even exists in the plugin is because some other plugins are still using user levels and not properly using capabilities. The ability to change this in the Members plugin will be removed at some point in the future.

  7. Steve Taylor
    Member
    Posted 2 years ago #

    @Justin, yeah, http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/user.php#L496 is the problem. Since it's still in the core, and you've included members_remove_old_levels, I thought role editing would update the user level field without having to edit the user. But yeah - ideally the core should be fixed rather than tacking more workarounds onto plugins.

  8. jmanriquez68
    Member
    Posted 2 years ago #

    Thank you all for your answers and clarification. Much appreciated.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags