suburbia
Member
Posted 18 years ago #
Hey all, my WPMU install went great and everything is working well, although if a new user signs up and doesn't select to have a blog created, when they go to login they receive:
"You do not have sufficient permissions to access this page."
If the new user selects to have a blog created, there's no problem... what gives??
This is an ongoing topic for discussion. It appears that WPMU does not give new users a default role. Here's a hack offered by JoshEH to make new users to the main blog subscribers, but there still is no good fix for default role settings for sub-blogs within the community.
This is a rather important problem, so if anyone has another solution, it would be much appreciated...
ovgray
Member
Posted 18 years ago #
You can add a plugin to alter this behaviour. Here's one I've been sketching out - what it does is explained in the comments.
/*
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');
Hmm, I might be saving it wrong, but can't get it to work... this sounds like a nice fix though. Still, it would be better to avoid the problem altogether by providing all new users with default capabilities/role at signup.
ovgray
Member
Posted 18 years ago #
did you add <?php
at the beginning, ?>
at the end and put it in mu-plugins?
Sorry, should have given more details: I'm getting a "Parse error: syntax error, unexpected T_OBJECT_OPERATOR on line 26", which is
header( "Location: http://" . current_blog->domain. "/" );
JoshEH
Member
Posted 18 years ago #
I get the same error message BTW.
ovgray
Member
Posted 18 years ago #
Sorry. That line should read
header( "Location: http://" . $current_blog->domain. "/"
I don't know how the '$' disappeared from in front of 'current_blog->domain'. It was in the code when I copied it into the post.
JoshEH
Member
Posted 18 years ago #
Man was I being lazy, I didn't even look for typos. Yep it works now.
dubaidan
Member
Posted 17 years ago #
Merqtio said:
Here's a hack offered by JoshEH to make new users to the main blog subscribers, but there still is no good fix for default role settings for sub-blogs within the community.
Anyone figured out the sub-blog problem?
hm...
I have similar problem.
I need this: when new user is registered, he receives the Author role is his blog, instead of the Administrator (as on a default)
*sorry for my poor English
Hey folks, I'm trying to consolidate this question with other similar threads at a new thread here. See if this answers the question...
Has there been a solution to this problem? I tried to register as a user (no blog) - from the main site - and got the following error:
You do not have sufficient permissions to access this page.
What do I need to change and is there a plugin that solves this issue?
Thanks in advance for your help.
Can I assume this is no longer necessary, i.e. the code is absorbed into the latest release?
It hasn't been an issue for me since I upgraded to WPMU version 1.23 (it may have even have been fixed earlier). I believe it is now a standard fix in the more recent versions.