Plugin to change default landing page

I know how to modify elgg\actions\login.php to change the landing page after login.  However, I'd like to do that with a plugin.  I've used the skeleton plugin in the docs folder as a starting point.  My plugin path is elgg\mod\newlanding\ and within that folder I've created actions\newlanding and copied the original login.php file there and included my changes.  I think that I'm getting mixed up on the start.php file.  Here is what I've included.


elgg_register_event_handler('init', 'system', 'newlanding_init');

function newlanding_init() {

$action_base = elgg_get_plugins_path() . 'newlanding/actions/newlanding/';

elgg_register_action('newlanding/login', "$action_base/login.php");



I've searched through the site and it seems as though I have to use the elgg_unregister_action function to unregister the core login.php action.  However, when I add that bit to my newlanding_init I can't login because the action login doesn't exist.  

What am I doing wrong?  I know that I don't have much of a clue here but I'm trying.



  • From what I understood, if you are looking to redirect users after login in, why cant you simply use an event handler for login function and redirect the user as needed? (Sorry, if that is not your question)

  • From what I understood, if you are looking to redirect users after login in, why cant you simply use...

    $group = 'Elgg Beginners';  // LOL

    I appreciate all of the input.  There are quite a few different approaches mentioned here.  I think that the manual edit is what I should do at this point since the rest of the suggestions are beyond my level right now.  I'll get there though!  Seeing as how it's on the dev radar I think I'll just focus my energy on another task. 

    Maybe I should cut my teeth on something a little easier for my first challenge.  Recommendations?  A theme perhaps?

    Thanks again everyone!

  • No, Lee don't cave now.

    There are multiple options here, which may be overwhelming, but they can all work.  Get one of them to work, don't resort to hacking the core because it's superficially easier.

    I already gave you my code, and it's the closest to the changes you've already established, give that a try at least.

  • OK Matt... will do.  My toilet is fixe but I have to go and take the wife out on the town.  I'll start on it tonight or tomorrow and report back!

  • Here is a quick code, you can try it and report back. 

    elgg_register_event_handler('login', 'user', 'my_login_redirect');
    function my_login_redirect($event, $type, $user) {
        $url = elgg_get_site_url()."profile/".$user->username;

  • Yes webgalli's code will also do the job, no need to get frustrated  :)

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking