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

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1

How to display profileextender plugin fields ?

I added new fields with profileextender addon but I do not see how to display thoses fields in discussions.

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Only works for the profile .... which is why it's called Profile Extender. It adds fields such as school , or occupation and shows up in the user profile.

  • But here there is a handler to display the fields in discussion
    So it might be possible here.

  • migswdmigswd New
    edited September 14

    I found this way.

        /**
         * Add 'Flag' link for discussions.
         */
        public function discussionController_afterDiscussionMeta_handler($Sender, $Args) {
    
            // Get user-specific data
            $ProfileFields = Gdn::userModel()->getMeta($Sender->Discussion->InsertUserID, 'Profile.%', 'Profile.');
            // TEST : echo $Sender->Discussion->InsertUserID;
    
            //echo ' <dt class="ProfileExtend Profile'.'societe'.'">'.'Société : '.'</dt> ';
            //echo ' <dd class="ProfileExtend Profile'.'societe'.'">'.$ProfileFields['societe'].'</dd>'.'<br>';
            echo '<span class="ProfileExtend Profilesociete">'.$ProfileFields['societe'].'</span>';
            echo '<span class="ProfileExtend Profileregion">'.$ProfileFields['region'].'</span>';
            echo '<span class="ProfileExtend ProfileMandats">'.$ProfileFields['Mandats'].'</span>';
            echo '<span class="ProfileExtend Profilspecialites">'.$ProfileFields['specialites'].'</span>';
        }
    

    Now I just need the same but for the comments in the discussion.
    I need to find the userid for a comment.

    What is the handler I should use ? This one ?
    public function discussionController_insideCommentMeta_handler($Sender, $Args) {

    R_Jvrijvlinder
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    If you know the name of the field, it is relatively easy:

        public function discussionController_authorInfo_handler($sender, $args) {
            // Get all fields, if you need more than one:
            $allFields = Gdn::userModel()->getMeta( // From table UserMeta...
                $args['Author']->UserID, // ... for this UserID...
                'Profile.%', // ... get all fields beginning with "Profile."...
                'Profile.' // ...and strip the beginning "Profile." from the result
            );
            echo '<span class="MItem SomeDescriptiveClassName">'.$allFields['PhoneNumber'].'</span>';
            echo '<span class="MItem SomeDescriptiveClassName">'.$allFields['Whatever'].'</span>';
    
    
            // Alternative, if you need only one field:
            $someField = Gdn::userModel()->getMeta(
                $args['Author']->UserID,
                'Profile.Whatever',
                'Profile.',
                'This is a default value if the field is not set for this user'
            );
            echo '<span class="MItem SomeDescriptiveClassName">'.$someField['Whatever'].'</span>';
        }
    

    You can find the name of the field in the config. As you can see in the following example, it is not necesseraly equal to the label that you have used in the ProfileExtender settings!

    $Configuration['ProfileExtender']['Fields']['PhoneNumber']['FormType'] = 'TextBox';
    $Configuration['ProfileExtender']['Fields']['PhoneNumber']['Label'] = 'Phone Number';
    $Configuration['ProfileExtender']['Fields']['PhoneNumber']['Options'] = '';
    $Configuration['ProfileExtender']['Fields']['PhoneNumber']['Required'] = '1';
    $Configuration['ProfileExtender']['Fields']['PhoneNumber']['OnRegister'] = '1';
    $Configuration['ProfileExtender']['Fields']['PhoneNumber']['OnProfile'] = false;
    
    migswd
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    And if you want to show that info not only in discussions but also on the recent discussion list, you should better start with public function base_authorInfo_handler($sender, $args) {

    migswd
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Sorry, I haven't seen that you already found a way.

  • Thank you so much R_J !! Works great !!! :)

Sign In or Register to comment.