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

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.