Using WordPress ‘network_user_new_form’ PHP action

The network_user_new_form WordPress action fires at the end of the new user form in network admin.

Usage

add_action('network_user_new_form', 'your_custom_function');
function your_custom_function() {
  // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: network_user_new_form

Examples

Add a custom field to the new user form

add_action('network_user_new_form', 'add_custom_field_to_new_user_form');
function add_custom_field_to_new_user_form() {
  echo '<label for="user_company">Company</label>';
  echo '<input type="text" name="user_company" id="user_company">';
}

Add terms and conditions checkbox

add_action('network_user_new_form', 'add_terms_and_conditions_checkbox');
function add_terms_and_conditions_checkbox() {
  echo '<label for="terms_conditions">';
  echo '<input type="checkbox" name="terms_conditions" id="terms_conditions">';
  echo ' I accept the terms and conditions</label>';
}

Add a custom dropdown menu

add_action('network_user_new_form', 'add_custom_dropdown_menu');
function add_custom_dropdown_menu() {
  echo '<label for="user_role">User Role</label>';
  echo '<select name="user_role" id="user_role">';
  echo '<option value="admin">Admin</option>';
  echo '<option value="editor">Editor</option>';
  echo '</select>';
}

Add a custom message

add_action('network_user_new_form', 'add_custom_message');
function add_custom_message() {
  echo '<p>Please fill out all the required fields.</p>';
}

Add a hidden input field

add_action('network_user_new_form', 'add_hidden_input_field');
function add_hidden_input_field() {
  echo '<input type="hidden" name="user_origin" value="network_admin">';
}