1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Identity services

Discussion in 'XenForo Development Discussions' started by TerminalAddict, Jan 12, 2011.

  1. TerminalAddict

    TerminalAddict Active Member

    I'm working with message_user_info

    I'm doing something like this:
    	<xen:hook name="message_user_identities" params="{xen:array 'user={$user}'}">
    	 <xen:foreach loop="{$user.identities}" key="$service1" value="$account1">
    		<div id="{$service1}{$account1}">
    but alas .. no worky worky
    what am I doing wrong?
  2. TerminalAddict

    TerminalAddict Active Member

    fyi ... $user.identities looks like this:

  3. Jeremy P

    Jeremy P Well-Known Member

    Try to unserialize() it before passing it as a param.
  4. TerminalAddict

    TerminalAddict Active Member

    note sure how to do that?
    of if I need to?

    this code can found further down the template
                    <xen:foreach loop="{$user.identities}" key="$service" value="$account">
                        <dl class="pairsInline">
  5. Jeremy P

    Jeremy P Well-Known Member

    It's commented, and if you uncomment (remove the <xen:comments>) it'll throw an invalid argument for the foreach. My guess is it's something that's not really supported yet, but to be "fixed" in the future.

    The output $user.identities is throwing indicates it hasn't been unserialized after being pulled from the database. This would be done in the controller using the unserialize() function in PHP. You would have to write an add-on or wait until this is done in the core unfortunately.
  6. TerminalAddict

    TerminalAddict Active Member

    you're bang on !!

    unserialize ('the above content');
    array(3) {
    string(14) "TerminalAddict"
    string(14) "TerminalAddict"
    string(23) "terminapaul@hotmail.com"

    wonder what I can do now? ... learn how code an add-on.

    any clues?
  7. Brogan

    Brogan XenForo Moderator Staff Member

  8. Jeremy P

    Jeremy P Well-Known Member

    You would have to write an addon using a code listener for load_class_controller, extending controllers for pages that make use of message_user_info, and overwriting however $user is being set in the controller with an unserialized value for $user['identities'].

    Otherwise if you're comfortable editing files, you could open up XenForo_ControllerPublic_Thread (library/XenForo/ControllerPublic/Thread.php) and after line ~69..
    $posts $postModel->getAndMergeAttachmentsIntoPosts($posts);
    foreach ($posts as $key => $post)
    $posts[$key]['identities'] = unserialize($post['identities']);
    Not sure if the template is parsed for any other page, but the idea would be the same.
  9. TerminalAddict

    TerminalAddict Active Member

    bingo !!! that's the bugger ... not upgrade proof, but it achieves what I want I think

Share This Page