XF 2.0 Trying to create custom userfields with an add-on

Matt C.

Well-known member
I am trying to create some custom userfields with an add-on. This is what I've got so far in the Setup.php.
PHP:
<?php

namespace AH\GamerProfiles;

use XF\AddOn\AbstractSetup;

class Setup extends AbstractSetup
{
    public function install(array $stepParams = [])
    {
       $this->db()->insertBulk('xf_user_field', [
       [
        'field_id' => 'ah_playstation',
        'display_group' => 'contact',
        'display_order' => 70,
        'field_type' => 'textbox',
        'field_choices' => '',
        'match_type' => 'none',
        'match_params' => '',
        'max_length' => 0,
        'display_template' => '<a href="https://gamercards.exophase.com/psn/user/{$value}" class="gamerProfileTrigger"><i class="mdi mdi-playstation"></i><span class="username">{$value}</span><span><img src="//card.exophase.com/psn/{$value}.png" class="gamerProfile" /></span></a>'
      ],
      [
        'field_id' => 'ah_xbox',
        'display_group' => 'contact',
        'display_order' => 80,
        'field_type' => 'textbox',
        'field_choices' => '',
        'match_type' => 'none',
        'match_params' => '',
        'max_length' => 0,
        'display_template' => '<a href="https://gamercards.exophase.com/xbox/user/{$value}" class="gamerProfileTrigger"><i class="mdi mdi-xbox"></i><span class="username">{$value}</span><span><img src="//card.exophase.com/xbox/{$value}.png" class="gamerProfile" /></span></a>'
      ],
      [
          'field_id' => 'ah_steam',
          'display_group' => 'contact',
        'display_order' => 90,
        'field_type' => 'textbox',
        'field_choices' => '',
        'match_type' => 'none',
        'match_params' => '',
        'max_length' => 0,
        'display_template' => '<a href="https://gamercards.exophase.com/steam/user/{$value}" class="gamerProfileTrigger"><i class="mdi mdi-steam"></i><span class="username">{$value}</span><span><img src="//card.exophase.com/steam/{$value}.png" class="gamerProfile" /></span></a>'
      ],
    ], 'field_id');
    }

    public function upgrade(array $stepParams = [])
    {
        // TODO: Implement upgrade() method.
    }

    public function uninstall(array $stepParams = [])
    {
        // TODO: Implement uninstall() method.
    }
}

When I rebuild the add-on, the process goes well with no errors, however when I go to check, the user fields aren't there.

If anyone could tell me what I've done wrong, it would be greatly appreciated. Thank you!

EDIT: I tried actually installing the add-on (instead of rebuilding) on my production forum, and the fields were imported. Is there a way to get the fields imported on my dev forum without uninstalling it?
 
Last edited:
Top