wecreateyou
Expert
Super Volunteer
Member Likes (0)
How do I make login-redirect take users to their blogs homepage instead of the main site when they login. I tried the plugins I found in the forum but none seem to do what I need. I even tried Peter's Redirect and it has a variable which is nice but didn't work with the network as far as I can tell.
Thanks in advance.
Responses (9)
WPMU DEV Fanatic (joined October 2009) Likes (0)
Hi wecreateyou,
Unfortunately, that wouldn't be possible with the Login Redirect plugin itself as it requests a specific url for the redirect. And in fact, I haven't yet seen a way to achieve exactly that, so I'm hoping someone else around here might have some good ideas on this.
I was thinking that this could be done using the switch_to_blog() function, cycling through all the available blogs and checking if the logged in user is admin, but I don't have anything concrete on this as yet, just some jumbled code. I'll keep working at it and let you know if I'm able to hack together something that would work, though you might want to consider posting a job request if you need this right away.
http://premium.wpmudev.org/wpmu-jobs/
Cheers,
David
WPMU DEV Fanatic (joined October 2009) Likes (0)
Hmm, come to think about it, if you set the redirect url to yoursite.com/wp-admin/, it should redirect the users to their own sub-site dashboard as long as they don't have a role on yoursite.com. If you redirect them to yoursite.com/wp-admin/my-sites.php, if they're not automatically taken to their site dashboard they'll at least have the option right before them to be taken there.
Member (joined September 2008) Likes (0)
Thanks David,
I appreciate your reply, I'll try that and report back whatever I discover...
WPMUdev Rocks!
Member (joined April 2009) Likes (0)
Let us know how it goes. For now I'm gonna mark this one as resolved - though you can definitely reopen if needed.
Thanks!
WPMU DEV Fanatic (joined October 2009) Likes (0)
Woohoo! Just got it working on a test multisite after a bit too much work! You wouldn't need switch_to_blog() at all. You can simply pop the following in your theme's functions.php and it should work from there!
Had another member request something similar. Let me know if you have any trouble with it!
Cheers,
David
Member (joined September 2008) Likes (0)
Good stuff I tell you! Thanks @David. I'll let you know what the results are for me.
Member (joined April 2009) Likes (0)
Nice one David! I'd toss you some rep points, but that seems silly :D
Member (joined September 2008) Likes (0)
Working breezily... Thanks
Support Kangaroo (joined March 2011) Likes (0)
Greetings David :-)
I cannot seem to get this to work.
I copied the code above into the functions.php file of the theme of the main site and it did not work. Actually nothing changed that I am aware of.
Does it require the login redirect plugin to be activated?
or something more then just popping it into the functions.php?
Joe :-)
WordPress Questions?
We've got answers!
Find out more »