WordPress.org

Ready to get started?Download WordPress

Forums

What is the hook for that subdomain permissions page? (3 posts)

  1. mic10
    Member
    Posted 10 months ago #

    I've commented on here before about that permissions error page that comes up (on a subdomain install), when a user at user.mysite.com tries to login at mysite.com

    I want to remove that error message by css so it just leaves 'dashboard' and 'visit site' by doing:

    #error-page p:nth-of-type(1), #error-page p:nth-of-type(2), #error-page p:nth-of-type(3) {
    display:none !important;
    }

    But I can't find the hook for it.

    I have the following hooks for adding css on non frontend pages:

    add_action('admin_head', 'am_admin');
    function am_admin() {
       echo '<style type="text/css">
    /*css for admin*/
       </style>';
    }
    add_action('login_head', 'am_signup_register_activate');
    add_action( 'signup_header', 'am_signup_register_activate' );
    add_action('activate_header', 'am_signup_register_activate');
    function am_signup_register_activate() {
       echo '<style type="text/css">
    /*css for other stuff*/
    </style>';
    }

    I'v looked on wordpress hook references but can't get that permissions page error css code to work.

    Can anyone help me, thanks

  2. IIRC it doesn't have a hook yet.

  3. andym33
    Member
    Posted 10 months ago #

    Thanks for your reply Ipstenu. I keep trying to find ways of avoiding that permissions error page, it has been bothering me for so long, I have just found this bit of code on the forums if anyone is interested - this redirects back to your Site homepage:

    add_action('wp_login','go_home');
    function go_home(){
       wp_redirect( home_url() );
      exit();
    }

    Now you can hover over the my-sites link in the top admin bar and go to your blog. Surely this is better if users decide to login through your main site url.

    Also, I noticed when your on someone elses blog, clicking on the my-sites link directly instead of using the my-sites sub menu to go to your blog, you also go to that permissions error page. After looking in admin-bar.php in wp-includes it has:

    foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    		switch_to_blog( $blog->userblog_id );

    This code is inside the my-sites parent rather than outside so that is why that goes to that permissions error page so I worked out a way to rewrite the code in my functions.php to put that code on the outside, I'm no good with php, I tried a few things and somehow I got it to work perfectly.

    I just thought, is there a way to do the same thing by adding the switch_to_blog line and add_action('wp_login','go_to_blog'); together somehow?

Reply

You must log in to post.

About this Topic