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.
Thanks!
Lee
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
most likely the login form is called with elgg_view_form which automagically passes the action = view
So you will have to unregister the original action, and register your new action with the same name.
That's too complicated. Haven't tried, but you could define REFERER as the page you want to send the user to and set the input hidden returntorefer to true
You can change the action path in core/account/login_box, or pass your own action to elgg_view_form() in a custom view
Editing the core login.php file (although a no-no) seems to be much easier. I'd like to do the plugin for two reasons:
1. learning opportunity
2. do something that others can benefit from
Having said that, what you two have recommended is beyond my current level of understanding. Can either of you clarify?
Thanks!
I say core - what I mean is \elgg\actions\login.php. I can edit that file directly to accomplish what I want but I know that's not the preferred method.
Look at views/default/core/account/login_box. That's the view that wraps the login form. By default, elgg_view_form() will build the form action based on the form view path, e.g. forms/myplugin/add will use the action action/myplugin/add.
So, basically what you need to do:
1. Overload views/default/core/account/login_box with your own view
2. Change the action path to that of your new login action
That's it
OK, thanks! I'm about to fix a toilet (LOL). I'll look at this after I get through with that and report back!
Much appreciated!
I don't think the view needs to be overwritten, I stand by my original assessment it should only be 2 lines of code... I think maybe the way I explained it made it sound more complicated than it is:
Then whatever changes you need to do the in action you can do in your non-core file.
(note that the action may need to be public, I'm not sure about that)
mod/OverlySliders/start.php==
<?php
elgg_register_event_handler('init', 'system', 'OverlySliders_init');
function OverlySliders_init()
{
register_plugin_hook('index', 'system', 'OverlySliders_Index');
}
function OverlySliders_Index($hook, $type, $return, $params)
{
if ($return == true)
{
return $return;
}
// index.php can do whatever it needs to for loggedIn or loggedOut
if (!include_once(dirname(__FILE__) . "/index.php"))
{
return false;
}
return true;
}
?>
We're talking about ways to make this easier: http://trac.elgg.org/ticket/4275
- Previous
- 1
- 2
- Next
You must log in to post replies.