How to add custom fields to admin user creation form

Since Tendoo 1.4, it's possible to add custom field and to handle it within your module. This release introduced two functions for this.

The first one is "bind_filter", which is used to apply custom filter to a variable which is supposed to be used by tendoo.

The second is "register_fields", this function let you add green flag to a type POST variable.

Here is how to do it.

First : Add Custom Fields

<?php
// within init.php or backend.php  / frontend.php
bind_filter( 'user_form_fields' , 'custom_filter' );
function custom_filter( $current_fields ){
   $current_fields[]   =   array(
       'name'					=>	'admin_cellphone',
			'placeholder'		=>	__( 'User Cellpone' ),
			'label'					=>	__( 'Cellphone' ),
			'type'					=>	'text',
			'description'		=>	__( 'Enter user cellphone' ),
			'value'					=>	get_instance()->meta_datas->get_user_meta( 				'admin_cellphone' , riake( 'PSEUDO' , $user ) ) 
   ):
}

We use "get_instance()->meta_datas->get_user_meta(...)", in order to retreive the meta data "admin_cellphone", which is the input name for the custom field, saved on the database. This process will fill the custom field.

Now a custom field will be added to specified form. There are many type of form on Tendoo, Here is the list ).

Set a white card for POST indexes

If you want tendoo to save your custom field, you must give them a white card. To do that, you need to register POST index, by using "register_fields" function.
Like this

<?php
register_fields( 'user_form_fields' , array(
  'name'		=>	'admin_cellphone',
  'purify'	=>	function( $input ){
    return $input;
  } ) 
);

This function accepts as second parameter a "purify" function. It's not required, since Tendoo use its own purify function to clean post values.