The only last will win – You!

Only last will win


You are the only boss for your WordPress network

Change default role for owner of new created blog. Is it a problem? You setup multi-site WordPress network successfully and see, that quant of user created blogs grows. Excelent!
But you are not glad. You are not happy. What the reason? You are angry on all those new blogs owners. They do, what they want. They change, what they wish. They should make good posts only! Why all of them are administrators of their blogs? The Administrator should be only one – You. Only One will Win – You! The biggest thing, what you may allow to your WordPress managed network blogs owners – be the editors on their blogs.
That’s a joke, of course. But some time, somewhere… What to do, if text above describes your situation somehow? Don’t worry, try “Win Only One” WordPress plugin. Just setup and activate for Network. It will help you transparently. Your problem will be resolved in the full silence.
“Win Only One” WordPress plugin changes user role of just created new blog owner from ‘administrator’ by default to ‘editor’, as Only One will Win! 🙂 Plugin doesn’t require any tuning. It has not Settings or Options page and menu item. It just does its work.

What’s happening behind the scene?

When Network Administrator or multisite WordPress network user creates new blog WordPress executed wpmu_create_blog() function from wp-includes/ms-functions.php file. This function has this line of code inside:

980
 add_user_to_blog($blog_id, $user_id, 'administrator');

Thus, WordPress assigns ‘Administrator’ role by default to the 1st user, which it adds to the new created blog.
In order to change this situation we can use 'wpmu_new_blog' action, executed at the end of wpmu_create_blog() function. Thus, we need this code to be the only One Admin in the small hand-made universe, named your own WordPress multi-site Network.

  function woo_admin_to_editor($blog_id, $user_id) {
    switch_to_blog($blog_id);
    $user = new WP_User($user_id);
    if ($user->exists()) {
      $user->set_role('editor');
    }  
    restore_current_blog();
  }
 
  add_action( 'wpmu_new_blog', 'woo_admin_to_editor', 10, 2 );

Remember, this plugin will work for multi-site environment only.

download

Click on the red download button. Download this zip-file. Extract it to the wp-content/plugins directory. Activate plugin for the whole network. That’s all. The rest “Only One Win” WordPress plugin will make for you itself.

And let’s the most powerful (You) will win! 🙂

Tags: , , ,