WPMU permissions hack for new users

If you are using or administrating WordPress Multi-User you may have come across the following error message for new users creating just a login name (not getting blog):

You do not have sufficient permissions to access this page.

This problem can get pretty frustrating if you are using a single blog on WPMU that has several users. For example, I created one blog for my class this Summer that has six additional users. Each of the students created a login name without a problem, but when they tried to sign on to the site (and I had given them all editing permissions) they received the above message. This can be worked around clunkily with a couple of hard refreshes and a handy edit button on a post, but there is a better hack.

On the WPMU forums I found the following solution. According to this thread, and others like it, this is a more general issue with WPMU 1.0 and hasn’t really been addressed as of yet. However, as is often the case with open source applications, someone has come up with a quick hack that has worked perfectly for me thus far. Below is the code for the plugin to make this problem go away.

domain==$current_site->domain) { // logged in at main site -- no caps
// if user has blog, send user there - code copied from menu.php
$primary_blog = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '$user_ID' AND meta_key = 'primary_blog'" );
if( $primary_blog ) {
$newblog = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$primary_blog}'" );
if( $newblog != null ) {
header( "Location: http://" . $newblog->domain . $newblog->path . "wp-admin/" );
// user has no caps here
// user either has no existing primary blog of his/her own or did not log in at main site
// redirect to front page of the blog at which s/he logged in
header( "Location: http://" . $current_blog->domain. "/" );
add_action('admin_menu', 'adrx_nocaps_login');

Just copy the above code into a text editor, save it as adrx.php, and copy it into the mu-plugins folder of your WPMU install. That’s it! Hopefully this will be solved in the next version, for it is a pretty big problem if you are going to have a multi-user blog within this environment.

This entry was posted in WordPress, wordpress multi-user and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.