HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

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.