I am trying to add a button to the profile menu by the 'EDIT PROFILE' button.
I have added the following code to the start file of my plugin.....
elgg_register_plugin_hook_handler('register', 'SOMETHING_HERE', 'my_owner_menu_button');
But cannot find out what to add to the 'SOMETHING_HERE' bit of code.
Can anyone help me with this please ??
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.
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- JohnnyD@JohnnyD
JohnnyD - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- JohnnyD@JohnnyD
JohnnyD - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- iionly@iionly
iionly - 0 likes
- JohnnyD@JohnnyD
JohnnyD - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- JohnnyD@JohnnyD
JohnnyD - 0 likes
You must log in to post replies.menu:user_hover
If I remember correctly you'll need to set the section to 'action' for it to show up in the owner block
Hi Matt.
I think I might be trying to run before I can walk with this but I will try.
Do you mean like this...
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'cmy_upgrade_owner_block_menu');
and then set the action in a function.
I have been looking around the reference and docs and found this
Looks like what I might need as I only want the menu button to show when the user is logged in.
Thanks for your help!
@JohnnyD
Correct me, pls: Owner block or User hover?
For adding link on the owner block use this example:
For user hover use this hook:
Hi RvR,
Thank you for your help.
I am trying to add a button on the profile page with the 'edit avatar' and 'edit profile' like in this image.
I would like it to only show when the profile owner is logged in.
Sorry I copied the wrong bit of code in my last reply. It should have been...
Thanks to you both.
Use
@RvR: this will show the button to all logged in users and not exclusively to the page owner.
@JohnnyD: try this...
Add to the init function of your plugin:
and the callback function for this plugin hook is:
I think this should add the button on profile pages (visible only to the profile page owner). It will also add the link to the hover menu of user avatars (also only visible on your own). The entry in the hover menu is created automatically. I don't know how to get only the button on profile pages without the entry in the hover menu
@RvR Thanks for the code. It added the button to the sidebar instead of with the edit buttons. But it worked ok.
Also like iionly said it shows to all logged in users.
@iionly
Thanks for the help! I will try it tomorrow as my head is spinning now and I will only make mistakes. With the hover menu will work fine also. I will let you know how I get on tomorrow.
Thanks everyone.
No, those buttons are generated in a weird way - it comes from the user_hover menu, I've had to work with them before
elgg_register_plugin_hook('register', 'menu:user_hover', 'my_function');
function my_function($hook, $type, $return, $params) {
$item = new ElggMenuItem('button_name', elgg_echo('button_text'), $url);
$item->setSection('action');
$return[] = $item;
return $return;
}
@iionly and Matt
That worked great and it also added the link to the hover menu of user avatars which works well.
I worked most of yesterday on this with no luck but with your help got it working in 5 minutes this morning.
Thanks again for your help.