Mecha CMS

Code snippet collection for developers.

Custom Log In Redirection

Author: Taufik Nurrohman · 311 Views

Tweet

Redirect user to custom destination after logged in.

Table of Content

Method 1: URL 

  • http://mecha-cms.com/panel/::g::/enter?f[kick]=panel/::g::/page → go to the Page manager on enter (default)
  • http://mecha-cms.com/panel/::g::/enter?f[kick]=panel/::g::/state → go to the State manager on enter

Method 2: Hook 

Using hooks to replace hidden <input> element with <select> element:

1

$_path = Extend::state('panel', 'path', X);

// The select’s option(s)…
$_select = [
    'comment',
    'page',
    'state'
];

if (Route::is($_path . '/::g::/enter')) {
    $_values = [];
    foreach ($_select as $_value) {
        $_text = $language->{$_value};
        $_text = Config::get('panel.n.' . $_value . '.text', $_text);
        $_values[$_panel . '/::g::/' . $_value] = $_text;
    }
    Config::set('panel.f.enter.kick', [
        'type' => 'select',
        'title' => $language->to,
        'values' => $_values,
        'width' => true
    ]);
}

0 Comments

No comments yet.