Skip to main content
Topic: How to get user display name in hook integrate_prepare_display_context? (Read 2273 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to get user display name in hook integrate_prepare_display_context?

I tried to add icon next to username for topic author in topic view, but I can't figure out how to get display name from $message.

There is $message['poster_name'] but it returns username (login). I can't use anything from $output array, because it's multiplied on every next message in topic.
Is there way to get display name without file edits?

Re: How to get user display name in hook integrate_prepare_display_context?

Reply #1

I think you should really use $output and "remember" if you have already added it.
Something like:
Code: [Select]
static $added = false;

if ($added === false && $output['member']['id'] == $op_id)
{
    $output['member']['link'] = // add the image here (I think);
    $added = true;
}

The alternative, is a bit more "fancy"[1]: you may hook integrate_action_display_before and there attach a non-permanent hook to integrate_member_context in order to add the image next to the name.
Though I find it rather cool and I may use it in my multi-badge addon. O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: How to get user display name in hook integrate_prepare_display_context?

Reply #2

Thanks, works great now :)
I'll post package later, maybe someone will find it useful ::)

I tried to look for integrate_action_display_before but I couldn't find it anywhere

 

Re: How to get user display name in hook integrate_prepare_display_context?

Reply #3

There are 7 "generic" calls that may trigger different hooks depending on the arguments:
Code: (ErrorContext.class.php) [Select]
'integrate_' . $this->_name . '_errors'
Code: (SiteDispatcher.class.php) [Select]
'integrate_action_' . $hook . '_before'
'integrate_action_' . $hook . '_after'
Code: (Action.class.php) [Select]
'integrate_sa_' . $this->_name
Code: (GenericList.class.php) [Select]
'integrate_list_' . $listOptions['id']
Code: (Menu.subs.php) [Select]
'integrate_' . $menuOptions['hook'] . '_areas'
Code: (Profile.subs.php) [Select]
'integrate_' . $hook . '_profile_fields'

these will need some special documentation...

BTW, if you use $db_show_debug = true; in your Settings.php, you can see all the hooks called in each page in the footer. ;)
Bugs creator.
Features destroyer.
Template killer.