How do I add new input field on this code?
public function form( $instance )
{
$user_id = isset ( $instance['user_id'] ) ? $instance['user_id'] : array();
$user_id_num = count( $user_id );
$user_id[ $user_id_num + 1 ] = '';
$user_html = array();
$user_id_counter = 0;
foreach (array_values($user_id) as $name => $value)
{
$user_html[] = sprintf(
'User ID<br/><input type="text" name="%1$s[%2$s]" value="%3$s" class="widefat">',
$this->get_field_name( 'user_id' ),
$user_id_counter,
esc_attr( $value )
);
$user_id_counter += 1;
}
print 'New User' . join( '<br /><br />', $user_html );
}
Basically I wanted to add new input field Location right next to the User ID field and then change the foreach
so it also get the new user_location. How to I rewrite the code to achieve what I wanted?