HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

ProfileExtender Magic Fields

I'm fairly certain I have posted this in the wrong category, please move it accordingly, I'm guessing a 3.x support category will be a thing when it's a full stable release.

Nonetheless I wanted to ask about the basic yet useful plugin ProfileExtender or to be more specific the "magic fields"

  public $MagicLabels = ['Twitter', 'Google', 'Facebook', 'LinkedIn', 'GitHub', 'Instagram', 'Website', 'Real Name'];

Which I happened to find while digging through the files to see how I could possible add new field options (actually I wanted to add twitter so was very happy when I found the Twitter option and that it worked perfect.. yay)

So I guess my question would be how can I add more "magic fields" like twitter/facebook, linkedin etc etc where input is given but the url or whatever is done plugin side.. the obvious method would seem to be to hack the file directly however that would likely lead to loss of fields on every update leaving me to ask do overrides exist ?

A way I can clone a specific file from the plugin and override it with my own - bit like how Joomla! templates use /templates/template_name/html/mod_wrapper/view.php

As noted above I'm using Vanilla 3.0 RC1 - I'm unsure on support policies so if none is offered till stable thats cool but would appreciate some feedback on the concept of expanding/overriding a plugin file i.e is it possible .

Tagged:

Comments

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    If you have already looked through the source you might have found that comment:

    * @todo Dynamic magic field filtering/linking

    It's on the todo list and therefore not implemented yet.


    Maybe extending that plugin is possible like that (below code is totally untested):



    class ProfileExtenderExtenderPlugin extends ProfileExtenderPlugin {
       public function __construct() {
           parent::construct();
           $this->MagicLabels[] = 'Whatever';
       }
    
       public function parseSpecialFields($fields = []) {
           if (!is_array($fields)) {
               return $fields;
           }
           $value = $fields['Whatever'] ?? false;
           if ($value) {
               $value = Gdn_Format::text($value);
               $fields['Whatever'] = // process somehow
           }
    
           return parent::parseSpecialFields($fields);
       }
    }
    

    Not sure if this would work though...

Sign In or Register to comment.