Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

How to use ProfileExtender to show users state

I setup a field in profile extender called 'State/Location' and I'm trying to get the information to display next to users names when they post. I found a snippet of code from @peregrine but I'm uncertain how to modify it to correctly do what I'm trying to do.

       public function DiscussionController_AuthorInfo_Handler($Sender) {
            $this->_AttachTitle($Sender);
           $Type= $Sender->EventArguments['Type'];
            if ($Type == 'Discussion') {
            $Author = $Sender->EventArguments['Discussion'];
            } else {
            $Author = $Sender->EventArguments['Comment'];
            }
            $AuthorID = $Author->InsertUserID;
            $NameofProfileField = "Profile.Testing";
            $SQL = Gdn::SQL();
            $this->PfeData = $SQL
            ->Select('*')
            ->From('UserMeta')
            ->Where(array('UserID' =>$AuthorID,'Name' => $NameofProfileField ))  
            ->Get()->FirstRow(DATASET_TYPE_ARRAY);
            echo WrapIf(htmlspecialchars(GetValue('Value', $this->PfeData)), 'span', array('class' => 'MItem AuthorTesting'));  
            }

Any suggestions would be welcome!

Comments

Sign In or Register to comment.