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.
<?php
/*
Plugin Name: ADRX No Caps User Login
Plugin URI:
Description: This plugin determines what happens when a user logins in at a blog for which s/he has no capabilites.
*/
function adrx_nocaps_login() {
global $current_site, $current_blog, $current_user, $user_ID, $wpdb;
if (!is_blog_user() || !is_site_admin) { // no caps and not site admin
if ($current_blog->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/” );
exit;
}
}
}
// 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. “/” );
exit;
}
}
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.

Related posts

0 Responses to “WPMU permissions hack for new users”


  1. No Comments

Leave a Reply




EDUPUNK: DIY EdTech

about

bavatuesdays.com is an ongoing conversation about media of all kinds ...

Testimonials:

Generations from now, they won't call it the Internet anymore. They'll just say, "I logged on to the Jim Groom this morning.
-Joe McMahon
Everything Jim Groom touches is gold. He's like King Midas, but with the Internet.
-Serena Epstein

I am Jim Groom

Find out more about me here.

browse the bavarchive

I'm a twit

random gems from bavarchive

Flickr Photo Gallery Selector 2 April 2008 Calendar for the Bam Cinematek The Wanderers BDP RSS Output Format (4) Domain Mapping Tab Air Raid Vault
View more photos >

My netflix


Grizzly ManThe HitcherMy Neighbor Totoro

Polls

What are your five favorite film adaptations of a Stephen King novel or story?

  • The Shining (1980) by Stanley Kubrick (23%, 34 Votes)
  • Shawshank Redemption (1994) by Frank Darabont (21%, 32 Votes)
  • Stand by Me (1986) by Rob Reiner (18%, 27 Votes)
  • Misery (1990) by Rob Reiner (17%, 25 Votes)
  • The Green Mile (1999) by Frank Darabont (13%, 19 Votes)
  • Carrie (1976) by Brian DePalma (11%, 17 Votes)
  • The Dead Zone (1983) by David Cronenberg (8%, 12 Votes)
  • Creepshow (1982) by George Romero (5%, 7 Votes)
  • Pet Cemetary (1989) by Mary Lambert (5%, 7 Votes)
  • The Mist (2007) by Frank Darabont (4%, 6 Votes)
  • Firestarter (1984) by Mark L. Lester (3%, 4 Votes)
  • The Running Man (1987) by Paul Michael Glaser (3%, 4 Votes)
  • Cujo (1983) by Lewis Teague (2%, 3 Votes)
  • Christine (1983) by John Carpenter (2%, 3 Votes)
  • Children of the Corn (1984) Fritz Kiersch (2%, 3 Votes)
  • Cat's Eye (1985) by Lewis Teague (1%, 2 Votes)
  • Dreamcatcher (2003) by Lawrence Kasdan (1%, 2 Votes)
  • Maximum Overdrive (1986) by Stephen King (1%, 2 Votes)
  • The Lawnmower Man (1992) by Brett Leonard (I imagine Stephen King would suggest this should not be on the list) (1%, 2 Votes)
  • Dolores Claibourne (1995) by Taylor Hackford (1%, 2 Votes)
  • The Dark Half (1993) by George Romero (1%, 2 Votes)
  • Apt Pupil (1998) by Bryan Singer (1%, 1 Votes)
  • Thinner (1996) by Tom Holland (1%, 1 Votes)
  • Needful Things (1993) by Fraser Clarke Heston (1%, 1 Votes)
  • Silver Bullet (1985) by Daniel Attias (1%, 1 Votes)
  • Sleepwalkers (1992) by Mick Garris (1%, 1 Votes)
  • The Mangler (1995) by Tobe Hooper (0%, 0 Votes)
  • Sometime's They Come Back (1991) by Tom McLoughlin (0%, 0 Votes)
  • Creepshow 2 (1987) by Michael Gornick (0%, 0 Votes)
  • Graveyard Shift (1990) by Ralph S. Singleton (0%, 0 Votes)

Total Voters: 150

Loading ... Loading ...