Advertisement:

Author Topic: SOLVED The login page redirects to the email page after login  (Read 786 times)

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
SOLVED The login page redirects to the email page after login
« on: February 01, 2018, 11:18:09 am »
If the user gets a mail and clicks on

https://example.com/user/items
or
https://example.com/user/dashboard

It will be redirected to the login page.
After login, the page redirects to the mail page.
Tested on: Firefox 58.0.1 / Ubuntu and Opera /android.

Has anyone else noticed this?

EDIT:
How to redirect always to user dashboard after login?

I think this is something new, because I did not noticed this until now.

« Last Edit: February 01, 2018, 12:44:00 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: The login page redirects to the email page after login
« Reply #1 on: February 01, 2018, 11:42:56 am »
oc-includes/osclass/controller/login.php

Code: [Select]
$url_redirect = osc_get_http_referer();This is not getting the /dashboard or /items link, but the email page in which the link was clicked.

....

Code: [Select]
osc_run_hook("after_login", $user, $url_redirect);
So in theme's functions.php file
EDITED with  else return $url_redirect;
Code: [Select]
<?php
function mc_redirect_to_dashboard_after_user_login($url_redirect) {
 if(
strpos(osc_base_url(),$url_redirect)===false){
   return 
osc_user_dashboard_url();
 }
 else return 
$url_redirect;
}
osc_add_filter('correct_login_url_redirect''mc_redirect_to_dashboard_after_user_login');
?>

« Last Edit: February 10, 2018, 04:55:32 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
SOLVED Redirect to user profile page after user validation
« Reply #2 on: February 01, 2018, 12:02:50 pm »
It would be nice to redirect the user after (registration and) user validation to /user/profile

EDIT:
oc-includes/osclass/controller/register.php

replace

Code: [Select]
                                            osc_run_hook('validate_user', $user);

                                            osc_add_flash_ok_message( _m('Your account has been validated'));
                                        } else {
                                            osc_add_flash_ok_message( _m('Account validation failed'));
                                        }
                                        $this->redirectTo( osc_base_url() );

with

Code: [Select]
                                            osc_run_hook('validate_user', $user);

                                            osc_add_flash_ok_message( _m('Your account has been validated'));
                                        } else {
                                            osc_add_flash_ok_message( _m('Account validation failed'));
                                        }
                                        $this->redirectTo( osc_user_profile_url() );


and the functions.php from the theme solution would be
(EDIT the next function doesn't work....): !!!

Code: [Select]
<?php
function mc_redirect_to_profile_after_user_validation($user) {
osc_add_flash_ok_message_m('Your account has been validated'));
header('Location:'.osc_user_profile_url());
}
osc_add_hook('validate_user''mc_redirect_to_profile_after_user_validation');
?>
« Last Edit: April 20, 2018, 09:38:29 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: The login page redirects to the email page after login
« Reply #3 on: February 10, 2018, 04:54:58 pm »
oc-includes/osclass/controller/login.php

Code: [Select]
$url_redirect = osc_get_http_referer();This is not getting the /dashboard or /items link, but the email page in which the link was clicked.

....

Code: [Select]
osc_run_hook("after_login", $user, $url_redirect);
So in theme's functions.php file

Code: [Select]
<?php
function mc_redirect_to_dashboard_after_user_login($url_redirect) {
 if(
strpos(osc_base_url(),$url_redirect)===false){
   return 
osc_user_dashboard_url();
 }
 else return 
$url_redirect;
}
osc_add_filter('correct_login_url_redirect''mc_redirect_to_dashboard_after_user_login');
?>


I see an interesting issue here..
If I type the url of the site and then login button, after login the page is redirected to

https://example.com/index.php

But the page is white. I don't see any error in the logs and if I hit enter on the url the page loads ok.

If I refresh the page nothing happens, the page remains empty.

I check the $url_redirect in this case and it's osc_base_url(); so https://example.com

Any Iideas?



SOLVED:))))
I edited the above function. I forgot

Code: [Select]
else return $url_redirect;
« Last Edit: February 10, 2018, 04:56:29 pm by marius-ciclistu »

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: SOLVED The login page redirects to the email page after login
« Reply #4 on: April 20, 2018, 01:33:55 am »
This does not seem to work all the time. I know it worked for me once and I checked functions.php to make sure I have this function but when I login it sends to the main page. Can someone confirm if this works or if there is a better solution to redirect user after login?  Thanks!

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: SOLVED The login page redirects to the email page after login
« Reply #5 on: April 20, 2018, 09:25:26 pm »
Hi. There are 2 things here. Redirect after user validation and redirect after login. The first works only with core mod.(i wrote there is doesn't work for validation with functions.php function).
The second sends to main page if you clicked log in from main page or from another url address(ex yahoo mail).
« Last Edit: April 20, 2018, 09:36:15 pm by marius-ciclistu »