Extending Field Types (for developers): Revision

Last updated by Jeroen Dalsem

Since version 4.1 BETA it is possible to extend the field types that can be used when create new profile/group fields.

This can be done by the following code:

// add following to init()

--------------------

$options = array();
$options["show_on_register"] = true;
$options["mandatory"] = true;
$options["user_editable"] = true;
$options["output_as_tags"] = true;
$options["admin_only"] = true;

$fieldtype = "text";

add_custom_field_type("custom_profile_field_types", $fieldtype, elgg_echo($fieldtype), $options);

--------------------

If you want to extend group profile types replace "custom_profile_field_types" with "custom_group_field_types"

At the moment group types only support output as tags and admin only as an option.

The fieldtype is used by input/fieldtype and output/fieldtype so when extending, make sure these fieldtypes are available.

Also make sure this plugin is enabeld when calling the add_custom_field_type function.

Jeroen Dalsem

Owner of ColdTrick IT Solutions, developing social networking sites for the dutch market

History