Login to another page besides the dashboard

Discussion in 'General discussions' started by droidman, May 9, 2019.

  1. droidman

    droidman Member

    Joined:
    Dec 12, 2017
    Messages:
    32
    Likes Received:
    2
    S.E:
    2019-11-05 00:35:53
    L.T:
    Regular
    L.C:
    2
    Is it possible anywhere on mw to set up the landing page after login ?
    I don't usually take much time on the main dashboard for the admin and normal users also have complained to me about slow logins since the dashboard is loading a lot of data most of them don't really look into.
    Going straight to the campaigns would be good for most users and in the admin setting up another faster page would also help me a lot.
    I wanted to know if there is a way to do this besides messing with the php.
    thanks
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,254
    Likes Received:
    2,382
    Possible only from PHP, the change is rather simple:

    create the file apps/customer/config/main-custom.php and place this into it. Save and that's it. Safe on upgrades, etc.
    PHP:
    <?php defined('MW_PATH') || exit('No direct script access allowed');

    return array(
        
    'components' => array(
            
    'customer' => array(
                
    'returnUrl' => array('campaigns/index'),
            ),
        ),
    );

     
    droidman likes this.
  3. droidman

    droidman Member

    Joined:
    Dec 12, 2017
    Messages:
    32
    Likes Received:
    2
    S.E:
    2019-11-05 00:35:53
    L.T:
    Regular
    L.C:
    2
    It worked for the login as a customer, directly to the /customer/ logged in and worked.
    as an admin if i try to impersonate an user it goes to the dashboard, and as an admin how do i make the admin also go to a default page? thanks again
     
  4. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,254
    Likes Received:
    2,382
    @droidman - we don't have any hook for that url BUT we can make one for future versions, so here's what you have to do:
    1. Open /apps/backend/controllers/CustomersController.php and at line 327 you have:
    PHP:
    $this->redirect(Yii::app()->apps->getAppUrl('customer''dashboard/index'true));
    replace that line with:
    PHP:
    $url Yii::app()->apps->getAppUrl('customer''dashboard/index'true);
    $url Yii::app()->hooks->applyFilters('redirect_url_after_impersonate_customer'$url$customer);
    $this->redirect($url);
    Then save your file.

    Next, open apps/init-custom.php (create it if missing) and place this code inside:
    PHP:
    <?php

    Yii
    ::app()->hooks->addFilter('redirect_url_after_impersonate_customer', function($url$customer){
       return 
    Yii::app()->apps->getAppUrl('customer''campaigns/index'true);
    });
     
    Last edited: May 10, 2019
    droidman likes this.
  5. droidman

    droidman Member

    Joined:
    Dec 12, 2017
    Messages:
    32
    Likes Received:
    2
    S.E:
    2019-11-05 00:35:53
    L.T:
    Regular
    L.C:
    2
    maybe it is cached or something the second modifications did not work yet. but already done.
     
  6. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,254
    Likes Received:
    2,382
    How does your apps/init-custom.php file looks like now ?

    I am pretty sure the change works, i tested it before i gave you the code.
     
    Last edited: May 10, 2019
  7. droidman

    droidman Member

    Joined:
    Dec 12, 2017
    Messages:
    32
    Likes Received:
    2
    S.E:
    2019-11-05 00:35:53
    L.T:
    Regular
    L.C:
    2
    i followed the steps and worked for the customers, for the backoffice it keeps sending me to the dashboard of the users, and when i login to the backoffice i keep going to the dashboard too. im going to see if i placed the code too low on the file or something similar
     
  8. droidman

    droidman Member

    Joined:
    Dec 12, 2017
    Messages:
    32
    Likes Received:
    2
    S.E:
    2019-11-05 00:35:53
    L.T:
    Regular
    L.C:
    2
    What i did was:
    /apps/backend/controllers/CustomersController.php line 327
    Code:
     //$this->redirect(Yii::app()->apps->getAppUrl('customer', 'dashboard/index', true));
            $url = Yii::app()->apps->getAppUrl('customer', 'dashboard/index', true);
            $url = Yii::app()->hooks->applyFilters('redirect_url_after_impersonate_customer', $url, $customer);
            $this->redirect($url);
    
    apps/init.php
    placed near the end of the file since if i put it anywhere on top it gives me a 500 error
    Code:
    $app->run();
    Yii::app()->hooks->addFilter('redirect_url_after_impersonate_customer', function($url, $customer){
       return Yii::app()->apps->getAppUrl('customer', 'campaigns/index', true);
    });
    
     
  9. droidman

    droidman Member

    Joined:
    Dec 12, 2017
    Messages:
    32
    Likes Received:
    2
    S.E:
    2019-11-05 00:35:53
    L.T:
    Regular
    L.C:
    2
    done, worked now, placed the code before
    $app->run();
    and now it works. only admin now goes to the dashboard, no problem, slow but i can live with it untill an new update or something.
    Thanks
     
  10. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,254
    Likes Received:
    2,382
    I said apps/init-custom.php If the file does not exist, create it ;)
     
  11. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,254
    Likes Received:
    2,382
    I am sorry, i guided you wrong, i see i kept saying apps/init.php when actually i should have said apps/init-custom.php.
    Sorry for that.
     

Share This Page