WordPress.org

Ready to get started?Download WordPress

Forums

Restrict Categories
Role vs. user restrictions (2 posts)

  1. mkalis
    Member
    Posted 2 years ago #

    Thanks for the plugin! Much simpler and more efficient than User Access Manager that I used before (fits my needs better).

    However, there is a bug that can be easily fixed (I'm using newest plugin's version - 2.5). The problem was that I restricted Author access to 'uncategorized' by default, but then I set some individual user restrictions. After saving, those users that I had not changed restrictions individually (no categories were checked for them), actually saw all of the categories, instead of just 'uncategorized'.

    I traced the problem to line 397, originally:

    $settings_user = get_option( 'RestrictCats_user_options' );
    
    /* Selected categories for User overwrites Roles selection */
    if ( is_array( $settings_user ) && !empty( $settings_user[ $user_login . '_user_cats' ] ) ) {
    	/* Strip out the placeholder category, which is only used to make sure the checkboxes work */
    	$settings_user[ $user_login . '_user_cats' ] = array_values( array_diff( $settings_user[ $user_login . '_user_cats' ], array( 'RestrictCategoriesDefault' ) ) );

    Saving user settings adds 'RestrictCategoriesDefault' to all the users in the page, which means that for all those users $settings_user[ $user_login . '_user_cats' ] will not be empty.

    The simple solution is to move the lines around like this:

    /* Get selected categories for Users */
    $settings_user = get_option( 'RestrictCats_user_options' );
    
    /* Strip out the placeholder category, which is only used to make sure the checkboxes work */
    $settings_user[ $user_login . '_user_cats' ] = array_values( array_diff( $settings_user[ $user_login . '_user_cats' ], array( 'RestrictCategoriesDefault' ) ) );
    
    /* Selected categories for User overwrites Roles selection */
    if ( is_array( $settings_user ) && !empty( $settings_user[ $user_login . '_user_cats' ] ) ) {

    I don't think this messes anything else up.

    http://wordpress.org/extend/plugins/restrict-categories/

  2. Caramboo
    Member
    Posted 2 years ago #

    Thanks mkalis. I had the same issue and your fix, fixed it!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic