I'm struggle with implementing a custom input field on the screen of a Site Info in a Network. I've managed to create a field with help of this post but i have problems with saving the value.
When i output the $_POST variable in the admin_footer-function, it is an empty array.
<?php
add_action('admin_footer', 'pg_custom_site_options');
function pg_custom_site_options(){
global $pagenow;
if( 'site-info.php' == $pagenow ) {
global $details;
$blog_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
if ( ! $blog_id ) wp_die( __('Invalid site ID.') );
$saved_value = get_blog_option( $blog_id, 'blog_order');
?>
<table>
<tr id="user16975_custom_options">
<th scope="row">Order</th>
<td><input type="text" size="5" name="blog[blog_order]" value="<?php echo esc_attr( $saved_value ) ?>" ></td>
</tr>
</table>
<script>
jQuery(function($){
$('.form-table tbody').append($('#user16975_custom_options'));
});
</script>
<?php
// DON'T USE IT - SEE MY THE ANSWER BEHIND
// ---------------------------------------
// Use a default value here if the field was not submitted.
// $new_field_value = '0';
//global $_POST; // Just a Test
// echo var_dump($_POST); // Is an empty array :(
// if ( !empty($_POST['blog']['blog_order']) ){
// $new_field_value = $_POST['blog']['blog_order'];
// }else{
// echo "nothing to do here";
// }
// save option into the database
// update_option( 'blog_order', $new_field_value);
}
}
?>
The strange part is, all values are presented after submit / reload of the site in Chrome Developer Tools or Firebug.