I'm using Elgg 2.3.14 and looking to override/extend the logout action to include some custom code. My plugin /var/www/html/mod/my-plugin/actions/logout.php has been created which has my custom code... however none of my code is being executed. Do I need to register my custom action in the start.php and include an "actions" property in the elgg-plugin.php under my plugin's root directory? If so, I couldn't find what the actual structure for including actions in elgg-plugin.php was.
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.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- TCB@tblack06
TCB - 0 likes
- TCB@tblack06
TCB - 0 likes
- TCB@tblack06
TCB - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- TCB@tblack06
TCB - 0 likes
- TCB@tblack06
TCB - 0 likes
- TCB@tblack06
TCB - 0 likes
You must log in to post replies.In first, elgg-plugin.php is not an Elgg 2 file but Elgg 3.
For custom Elgg 2 action you need to register it in your start.php.
Thanks,, that worked.. another question regarding my custom logout. I'd like to update the account menu to point to that new logout action. currently I have this in my start.php:
$item = elgg_get_menu_item('topbar', 'logout');
if ($item) {
system_message("got item");
$item->setParentName('account');
$item->setText(elgg_echo('logout'));
$item->setPriority(104);
$item->setHref('action/tsnlogout');
$item->setName(elgg_echo('tsnlogout'));
} else {
system_message("didn't get item");
}
but the menu isn't updating with the new info and my system message "didn't get item" prints out when the page loads.
currently reading documentation at:
http://reference.elgg.org/lib_2views_8php.html#aad8e0d385f58c77851953a5f7f8c5f27
found it... nevermind :-) added 'parent_name' property when registering the menu item.
Use menu hook.
Another way is:
So, you don't need to add the menu's hook.
In this case you should use a hook.
My suggestion is a new Class:
start.php
\mod\your-cool-plugin\classes\MyPlugin\Menus.php
Or something else... Learn, try, search
ok.. so now, I'm looking for an easy way to remove the original logout menu. I see elgg_unregister_menu_item and tried:
elgg_unregister_menu_item('topbar', 'account/logout');
but that didn't work.. Guessing I need to somehow get the parent item and then somehow call out the child 'logout' item in order to remove it?
Also, I tried to add an image to my topbar menu that will link to another page. I have factChain-Pen-badg3.png located in my /var/www/html/mod/fc-plugin/graphic/factChain-Pen-badge3.png and have the following code in start.php:
$text = elgg_view('output/img', array(
'src' => elgg_get_site_url(). 'mod/fc_plugin/graphic/factChain-Pen-badge3.png',
'alt' => '', 'class' => '',
'title' => '',
'width' => '',
'height' => '',
));
elgg_register_menu_item('topbar', array(
'name' => 'factChainPen',
'href' => 'https://mytesturlFC.com',
'text' => $text,
'priority' => 1000,
'section' => 'alt',
));
doesn't appear at all :-(
Thanks for the help, yes learn,try,search is the best approach, some of these items have required a quick turnaround so sometimes the research time makes it difficult to hit some deadlines.. It doesn't feel good asking for solutions without being thorough first so I know where you're coming from. So thanks for all the help you've provided thus far. This is my first project with elgg and php so it has definitely been a learning experience.