MU Advanced: Issues and Discussion
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • July 31, 2010, 05:46:22 PM
Home Forums Contact Tags FAQ Links News Login Register
* *
Navigation Menu
Search

Random Quotes
Ever mind the rule of three, Three times your deeds return to thee. This lesson well, thou must learn, thee only gets what thou does earn.
- Lady Gwen
Pages: [1]   Go Down
  Print  
Author Topic: redirect before reaching wp-login.php  (Read 1972 times)
0 Members and 1 Guest are viewing this topic.
dimensionmedia
Newbie
*

Karma: 0
Offline Offline

Posts: 1


View Profile
« on: July 22, 2008, 12:26:54 PM »

Greetings all.

I'm looking for a way if someone attempts to go to the wp-login.php of a created blog to be redirected to the blog's homepage itself. I was hoping to do this without editted the WPMU core code.

For example if i try to go here:
http://xxx.com/davidbisset/wp-login.php

i get seamlessly redirected here:

http://xxx.com/davidbisset/

This should happen for anyone EXPECT for the already-logged in "master" admin (the admin when the WPMU site was first setup).

Any clues? I know how to do this AFTER the wp-login form is submitted but my point here is that i don't want anyone expect the "master" admin to even see this page. :-)
Logged
Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #1 on: July 22, 2008, 02:16:32 PM »

There's a header hook in wp-login.php. Add a redirect there.

However, if the main admin isn't logged in, you're stuck.

Best bet would be to make a copy of the login file, and rename it to something only you know. Then use that to log in when you happen to get logged out on occasion.

Then just put a header redirect at the top of wp-login.php
Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« Reply #2 on: July 22, 2008, 03:46:09 PM »

You can also write a plugin, that from a PHP perspective checks the URL, and does a redirect. So for example...

Code:
if ( 0 === stripos($_SERVER['REQUEST_URI'],"/wp-login.php") )
{
    header("Location: $location_to_redirect_to");
    exit();
}

If this code is in the base of a mu-plugin, it will be exectuted before the page is rendered. You could also in this code check for things like logged in user, etc.... So you could only do the redirect if "!is_site_admin()" or something like that.

As Luke points out... you'll need some way to log in... so you either need to make another page that you can log in from or something... maybe check for a URL param that is some secret that only you know... or something.

Good luck!
Logged

Yep, that's me... riding my bike 204 miles in one day.
Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #3 on: July 22, 2008, 05:25:08 PM »

You can also write a plugin, that from a PHP perspective checks the URL, and does a redirect. So for example...


If this code is in the base of a mu-plugin, it will be exectuted before the page is rendered. You could also in this code check for things like logged in user, etc.... So you could only do the redirect if "!is_site_admin()" or something like that.

If it were me, I'd rather code it into the top of wp-login.php. Why fire up WP just to do a redirect?
Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« Reply #4 on: July 22, 2008, 05:34:47 PM »

Luke, I agree with your point about firing up the wp core...

But I guess the question is, if you don't want to hack the core... then can you do it in a plugin... the answer is... YES, and you can even do it relatively early... long before any filters or action handlers are fired.

Since this code can be in the global context of your plugin, I think it will get executed before the query is created... and most of the core is run... but I'll admit, I haven't tested this...so I could be completely full of brown stuff.

Logged

Yep, that's me... riding my bike 204 miles in one day.
ron_r
Key Master
*****

Karma: 4
Offline Offline

Posts: 1143



View Profile WWW
« Reply #5 on: July 25, 2008, 08:26:44 PM »

There is a redirect to hidden field in the login form. You can create wp-custom-login.php and and using the request uri populate the redirect to field but post the form to the regular wp-login.php.

No hacks or redirects required.
Logged

The key to problem solving is identifying the problem.
Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #6 on: July 25, 2008, 10:10:02 PM »

And that stops normal access to wp-login how, exactly?

Cheesy

Thank you. Come again.
Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
ron_r
Key Master
*****

Karma: 4
Offline Offline

Posts: 1143



View Profile WWW
« Reply #7 on: July 26, 2008, 05:16:38 PM »

I think I'm going to have to start reading twice   Grin
Logged

The key to problem solving is identifying the problem.
Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #8 on: July 26, 2008, 05:31:37 PM »

Well, once would be a good start.

Twice would be great.


We're not Andrea, so it's OK to turn off the selective hearing/reading/paying attention.

Tongue
Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
ron_r
Key Master
*****

Karma: 4
Offline Offline

Posts: 1143



View Profile WWW
« Reply #9 on: July 28, 2008, 08:08:32 PM »

My unread action has been hosing lately. There have been probably half a dozen times where it's come up empty (in the last few weeks) and there have been unread posts.

It's probably more to do with reading too fast. lol
Logged

The key to problem solving is identifying the problem.
Luke
Key Master
*****

Karma: 5
Offline Offline

Posts: 3710



View Profile WWW
« Reply #10 on: July 28, 2008, 09:55:31 PM »

Um, yeah. This site is always right. Tongue

Logged

10 frames?
Heh, that's for Quakers.

Note: This message may be Canadian friendly.

"Pornographic monster on the floor"
ron_r
Key Master
*****

Karma: 4
Offline Offline

Posts: 1143



View Profile WWW
« Reply #11 on: July 29, 2008, 08:30:21 PM »

Of course Cheesy
Logged

The key to problem solving is identifying the problem.
Tags: login redirect 

Pages: [1]   Go Up
  Print  
 
Jump to:  


Login
 
 
Recent Posts
Recent Topics
No new topics.
Hot Tags
Whos Online
7 Guests, 0 Users
Home Forums Contact Tags FAQ Links News Login Register