Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Page on Login #9

Open
jscooper opened this issue Nov 6, 2014 · 7 comments
Open

Home Page on Login #9

jscooper opened this issue Nov 6, 2014 · 7 comments
Assignees

Comments

@jscooper
Copy link

jscooper commented Nov 6, 2014

HI,

When a user logs in, he's brought to his profile/admin page. Is there a way to send him to the site's home page instead?

Thanks, and thanks for the plugin. Exactly what I need!

Jeff

@richard4339 richard4339 self-assigned this Nov 8, 2014
@richard4339
Copy link
Owner

This is honestly interesting to me.

The functionality I'm plugging in is core Wordpress functionality. According to their documentation, the function should redirect you at the very least back to the page you were on before. Is it even doing that for you? It appears I can overload some additional behavior here if need be, but it looks like it might require rolling a custom login page, which I'm not overly keen on doing. This plugin currently is like 10 lines of code for functionality (then a whole lot more for installation/uninstallation and setup).

Either way, I'll look. But what behavior are you seeing?

I'm putting these two links in here for my reference for when I look at this again and actually debug some.

http://codex.wordpress.org/Function_Reference/auth_redirect
https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/pluggable.php#L974

@richard4339
Copy link
Owner

I definitely need more information on what you're seeing.

I just spun up a sample Wordpress instance, installed my plugin, and tested it out.

I go to: http://test.local/

It redirects me here immediately: http://test.local/wp-login.php?redirect_to=http%3A%2F%2Ftest.local%2F&reauth=1
Note that it has the redirect_to in there

I login, and I'm back at: http://test.local/

If I try the sample post it always gives you while logged out: http://test.local/?p=1

It redirects me here immediately: http://test.local/wp-login.php?redirect_to=http%3A%2F%2Ftest.local%2F%3Fp%3D1&reauth=1

Login and I'm back where I started too.

Now, if I go directly to http://test.local/wp-login.php I do end up in the control panel.

What exactly are you seeing?

@jscooper
Copy link
Author

Hi Richard,

In the midst of typing up a long response, testing out different combinations of logins, etc., I think I found it! (it really hurt to delete three now irrelevant paragraphs, ah well)...

When I go in “clean” to (and this is an in-house development server, so the links won’t work for you):
https://wp.kingarch.com/wordpress/

I am redirected to https://wp.kingarch.com/wordpress/wp-login.php?redirect_to=https%3A%2F%2Fwp.kingarch.com%2Fwordpress%2F&reauth=1

When I log in from here, I am taken to the homepage.

But… if I log out, even from the homepage, I am directed back to here:
https://wp.kingarch.com/wordpress/wp-login.php?loggedout=true

When I log in as any user from THERE, I am taken to the Dashboard page.

Hope this helps!

Thanks,

Jeff

@Roadkill8D
Copy link

I am having this same problem. I didn't look into much more then reading these comments but i just ran a test on multiple computers and I'm being redirected to the Dashboard. I'm am also on a testing server if i was linked on to a single URL "http://www.Example.com" will it go to the home page?

@jscooper
Copy link
Author

Possibly. I finally notice that in my case is happened after I logged out then tried to log back in. I'm not sure if the URL wp directs me do when it initially loads is fixing the problem, or the url generated on log-out is causing it.

@Roadkill8D
Copy link

I'm using this for a large company and I don't want to look like an ass when its all said and done. It's not acceptable for me to have them log into the back end of Wordpress even the first time. The only one that should see WP is the admins logins. Its in the testing stages right now but when we go live i would like to have the least amount of speed bumps as i can and if i need to look for another plug in then thats what i will have to do.

I would also like to pad the developers pocket if this pulls me thought.

Cheers,

@kevinvess
Copy link

Try adding the following code to your theme's functions.php file:

/**
 * Set the URL to redirect to on login.
 *
 * @return string URL to redirect to on login. Must be absolute.
 **/
function my_login_redirect() {
  return site_url();
}
add_filter('login_redirect', 'my_login_redirect', 10, 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants