Community Documentation

v3 Knowledgebase

Create custom user fields

Custom User Fields

Suppose you have a "painters" user group and a "musicians" user group, each of them have different attributes. It wouldn't be right to ask a painter what instrument he prefers. In Phpfox v2 you can allow users to customize their profile based on what user group they are in by means of adding user group fields.

In addition we have a full example of this here

Adding a user group field

If you want to add a user field to the default "Musician" user group you can skip this next step, otherwise you need to create 2 tables in your database. In future versions you won't have to do this but for now:

Define the user group which will be using this user field. For this example we will say its the "painters" user group. Our table needs to have a name, so we would input this to the database:

CREATE TABLE `phpfox_painters_user` ( `user_id` int( 10 ) unsigned NOT NULL ,
UNIQUE KEY `user_id` ( `user_id` ) ) ENGINE = MyISAM;

CREATE TABLE `phpfox_painters_user_value` ( `user_id` int( 10 ) unsigned NOT NULL ,
UNIQUE KEY `user_id` ( `user_id` ) ) ENGINE = MyISAM;

Now we need to tell Phpfox that we have a user group which may have custom user fields so we go to the AdminP -> Users -> User Group Manager -> Manage User Groups. To the left of the user group "painters" there is a sort of arrow, click on it and then on "Manage User Settings", then click on the "Custom" module and set:

"Can edit own custom fields:" YES "Can have special custom fields:" YES "Custom Field Database Table Name:" painters_user

Finally, go to the AdminCP -> Users -> Custom Felds -> Add Custom Field.

  1. Product: If you have not yet created a product for your site you can use the Phpfox one
  2. Module: You can choose "user" since if you disable the user module there is no point in having user fields enabled.
  3. Group: Then choose where this user field should be located (in what tab when editing their profile)
  4. User Group: Painters since this example is using the user group "painters" (of course you choose the one that applies to your case.)
  5. Location: Where in the profile this field should be located. (When viewing the profile)

The rest of the fields are self explanatory. This should give you a working user group field you have chosen for your user group.

Changing the order of custom fields

You can change the order of the custom fields by going to the AdminCP -> Users -> Custom Fields -> Manage Custom Fields, there you only need to drag the icon to the left of the fields and then click on Update Order