How to change fields in Registration form

Renaming of fields

Note: Paste this code into your functions.php of your active theme

Personal Information Fields

  • first_name
  • last_name
  • phone
/*
 * On this example we are going to change the ff.
 * 1. Phone text into Telephone Number
 * 2. Text field to Number only
 */
function wpcfe_personal_info_fields_callback( $personal_fields ){
      $personal_fields['phone']['label'] = 'Telephone Number';
      $personal_fields['phone']['field'] = 'number';
      return $personal_fields;
}
add_filter( 'wpcfe_personal_info_fields', 'wpcfe_personal_info_fields_callback' );

Removing of fields

function remove_wpcfe_personal_info_fields_callback( $fields ){
    // Remove Phone field
    unset($fields['phone']);
    return $fields;
}
add_filter( 'wpcfe_personal_info_fields', 'remove_wpcfe_personal_info_fields_callback' );

Make the fields required.

/*
 * Make the First Name and Last Name required.
 */
function wpcfe_required_personal_info_fields_callback( $personal_fields ){
      $personal_fields['first_name']['required'] = true;
      $personal_fields['last_name']['required'] = true;
      return $personal_fields;
}
add_filter( 'wpcfe_personal_info_fields', 'wpcfe_required_personal_info_fields_callback' );

Adding new field

function add_wpcfe_personal_info_fields_callback( $fields ){
    // Remove Phone field
    $fields['new_text'] = array(
        'id'            => 'newfield',
        'label'         => 'New Field',
        'field'         => 'text',
        'field_type'    => 'text',
        'required'      => false,
        'options'       => array(),
        'field_data'    => array(),
        'field_key'     => 'newfield'
    );
    return $fields;
}
add_filter( 'wpcfe_personal_info_fields', 'add_wpcfe_personal_info_fields_callback' );

Billing Information

Renaming of fields

Personal Information Fields

    • billing_email
    • billing_company
    • billing_address_1
    • billing_address_2
    • billing_city
    • billing_postcode
    • billing_country
    • billing_state
/*
 * On this example we are going to change the ff.
 * 1. Country text into Country Available
 * 2. Select option field to Text
 */
function wpcfe_billing_address_fields_callback( $billing_fields ){
      $billing_fields['billing_country']['label'] = 'Country Available';
      $billing_fields['billing_country']['field'] = 'text';
      return $billing_fields;
}
add_filter( 'wpcfe_billing_address_fields', 'wpcfe_billing_address_fields_callback' );

Removing of fields

function remove_wpcfe_billing_address_fields_callback( $fields ){
    // Remove Country field
    unset($fields['billing_country']);
    return $fields;
}
add_filter( 'wpcfe_billing_address_fields', 'remove_wpcfe_billing_address_fields_callback' );

Make the fields required.

/*
 * Make the Country field required.
 */
function wpcfe_required_billing_address_fields_callback( $fields ){
      $fields['billing_country']['required'] = true;
      return $fields;
}
add_filter( 'wpcfe_billing_address_fields', 'wpcfe_required_billing_address_fields_callback' );

Adding new fields

function add_wpcfe_billing_address_fields_callback( $fields ){
    // Remove Phone field
    $fields['new_text'] = array(
        'id'            => 'newfield',
        'label'         => 'New Field',
        'field'         => 'text',
        'field_type'    => 'text',
        'required'      => false,
        'options'       => array(),
        'field_data'    => array(),
        'field_key'     => 'newfield'
    );
    return $fields;
}
add_filter( 'wpcfe_billing_address_fields', 'add_wpcfe_billing_address_fields_callback' );