User Role Editor Pro version 4.9

User Role Editor Pro version 4.9 is available for download.
The list of updates includes:

  • New tab “Default Roles” was added to the User Role Editor settings page. It is possible to select multiple default roles to assign them automatically to the new registered user.
  • CSS and dialog windows layout various enhancements.
  • ‘members_get_capabilities’ filter was applied to provide better compatibility with themes and plugins which may use it to add its own user capabilities.
  • Option was added to download jQuery UI CSS from the jQuery CDN.
  • Bug was fixed: Plugins activation assess restriction section was not shown for selected user under multi-site environment.

Read more User Role Editor Pro version 4.9

WordPress User Levels were deprecated just partially

Do you remember what are the WordPress user levels? If you don’t, then read this “User Levels” article at the WordPress Codex. As you may noted, at the begin of the article author says that user levels were finally deprecated in WordPress 3.0. Is it the full true? It is not, at least for the moment I write this post or saying in terms of WordPress versions, WordPress 3.8 still partially uses user levels.

I discovered that searching the answer for “User Role Editor”‘s user support request. User alby54 complains there, that when he tries to change the author of the post, he does not see users with new custom role assigned at the “Authors” dropdown list menu. Read more WordPress User Levels were deprecated just partially

Add secondary role to the new registered user

User Role Editor allows to assign multiple roles per user. What if you need that new registered users get multiple roles by default just after their registration?
For the time being you may do it with this piece of code included into your active theme functions.php file:

add_action( 'user_register', 'add_secondary_role', 10, 1 );

function add_secondary_role( $user_id ) {
    
    $user = get_user_by('id', $user_id);
    $user->add_role('screen_reader');

}

The code above adds to every new registered user the secondary role ‘screen_reader’ in addition to the default role ‘subscriber’ added by WordPress itself.

It works, but what will be when you switch to the other theme? Yes, it will stop working until you will not duplicate the code at new active theme functions.php file. If you change blog theme periodically or if you work with multi-site WordPress installation you may need more universal decision. With “multi-site” in mind we should use modified code:

if (is_multisite()) {
    add_action( 'wpmu_activate_user', 'add_secondary_role', 10, 1 );
} else {
    add_action( 'user_register', 'add_secondary_role', 10, 1 );
}
 
function add_secondary_role( $user_id ) {
 
    $user = get_user_by('id', $user_id);
    $user->add_role('screen_reader');
 
}

It works universally now as for single-site, as for multi-site WordPress installations. In order to not insert this code into every theme from themes poole which your subsites use, we may apply it another way.

WordPress has a convenient feature called “must-use” plugins. How does it work?

Create folder wp-content/mu-plugins, place there file with ‘.php’ extension and some PHP code inside. That’s it. This code will be executed by WordPress for every page request. There is no need to activate it. And it can not be deactivated with WordPress administrator interface.
So, create PHP file, for example must-use.php, insert code you see below into that file:

if (is_multisite()) {
    add_action( 'wpmu_activate_user', 'add_secondary_role', 10, 1 );
} else {
    add_action( 'user_register', 'add_secondary_role', 10, 1 );
}
 
function add_secondary_role( $user_id ) {
 
    $user = get_user_by('id', $user_id);
    $user->add_role('screen_reader');
 
}

Do not forget to add he required ‘<?php’ tag at the 1st line. Put must-use.php file into wp-content/mu-plugins folder. You did it.

P.S. I included this feature (multiple default roles) to my development plan. So it will appear as an option at the “User Role Editor Pro” soon.

Unlock Smart Manager for WooCommerce Shop Manager

In this post we will talk about how to unlock free version of Smart Manager for WooCommerce Shop Manager user.

If you ever used Smart Manager for e-Commerce WordPress plugin with WooCommerce e-shop, you may asked the question:
– Why WooCommerce super-user with ShopManager role does not see “Smart Manager” menu item under the “Products” menu?

For some reasons the free version of “Smart Manager” is available for the user with “Administrator” role only. But Pro version of “Smart Manager” has the user interface to configure what other WordPress roles are allowed to work with “Smart Manager”. So if you wish to use the full functionality of the “Smart Manager” consider to buy Pro version.
What to do if you wish to stay with free version of “Smart Manager”, but need make it available to the users without “Administrator” role? Is it possible to make free version of “Smart Manager” available for other user roles without changing its source code? Read more Unlock Smart Manager for WooCommerce Shop Manager