Using WordPress ‘network_site_info_form’ PHP action

The network_site_info_form WordPress action fires at the end of the site info form in the network admin.

Usage

add_action('network_site_info_form', 'your_custom_function', 10, 1);

function your_custom_function($id) {
  // Your custom code here

  return $id;
}

Parameters

  • $id (int): The site ID.

More information

See WordPress Developer Resources: network_site_info_form

Examples

Display additional site information

Display additional site information at the end of the site info form.

add_action('network_site_info_form', 'display_additional_site_info', 10, 1);

function display_additional_site_info($id) {
  $additional_info = get_blog_option($id, 'additional_info');
  echo '<p><strong>Additional Information:</strong> ' . esc_html($additional_info) . '</p>';

  return $id;
}

Add custom form field

Add a custom form field to the site info form for storing extra data.

add_action('network_site_info_form', 'add_custom_form_field', 10, 1);

function add_custom_form_field($id) {
  $extra_data = get_blog_option($id, 'extra_data');
  echo '<label for="extra_data">Extra Data</label>';
  echo '<input type="text" id="extra_data" name="extra_data" value="' . esc_attr($extra_data) . '">';

  return $id;
}

Display a custom message

Display a custom message at the end of the site info form.

add_action('network_site_info_form', 'display_custom_message', 10, 1);

function display_custom_message($id) {
  echo '<p><em>Remember to double-check all the information before saving.</em></p>';

  return $id;
}

Show site creation date

Show the site creation date at the end of the site info form.

add_action('network_site_info_form', 'show_site_creation_date', 10, 1);

function show_site_creation_date($id) {
  $creation_date = get_blog_option($id, 'registered');
  echo '<p><strong>Site Created:</strong> ' . esc_html($creation_date) . '</p>';

  return $id;
}

Add custom CSS class to form

Add a custom CSS class to the site info form for styling purposes.

add_action('network_site_info_form', 'add_custom_css_class', 10, 1);

function add_custom_css_class($id) {
  echo '<style>.form-table { background-color: #f9f9f9; }</style>';

  return $id;
}