The MU forums have moved to WordPress.org

"You do not have sufficient permissions to access this page." for new users? (15 posts)

  1. suburbia
    Member
    Posted 15 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??

  2. merqtio
    Member
    Posted 15 years ago #

    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...

  3. ovgray
    Member
    Posted 15 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');

  4. merqtio
    Member
    Posted 15 years ago #

    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.

  5. ovgray
    Member
    Posted 15 years ago #

    did you add <?php at the beginning, ?> at the end and put it in mu-plugins?

  6. merqtio
    Member
    Posted 15 years ago #

    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://&quot; . current_blog->domain. "/" );

  7. JoshEH
    Member
    Posted 15 years ago #

    I get the same error message BTW.

  8. ovgray
    Member
    Posted 15 years ago #

    Sorry. That line should read

    header( "Location: http://&quot; . $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.

  9. JoshEH
    Member
    Posted 15 years ago #

    Man was I being lazy, I didn't even look for typos. Yep it works now.

  10. dubaidan
    Member
    Posted 15 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?

  11. dimonprodigy
    Member
    Posted 15 years ago #

    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

  12. merqtio
    Member
    Posted 15 years ago #

    Hey folks, I'm trying to consolidate this question with other similar threads at a new thread here. See if this answers the question...

  13. jinglesnbells
    Member
    Posted 15 years ago #

    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.

  14. mrjcleaver
    Member
    Posted 14 years ago #

    Can I assume this is no longer necessary, i.e. the code is absorbed into the latest release?

  15. jimgroom
    Member
    Posted 14 years ago #

    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.

About this Topic

  • Started 15 years ago by suburbia
  • Latest reply from jimgroom