Пользовательский вход в Shortcode получил ошибку

Я создаю короткий код, который имеет форму входа, но кажется, что я получил ошибку при попытке входа в систему. это мой код.

function postCustomWPLogin($username, $password){ $creds = array(); $creds['user_login'] = $username; $creds['user_password'] = $password; $creds['remember'] = true; $user = wp_signon( $creds, false ); if ( is_wp_error($user) ){ echo $user->get_error_message(); }else{ $userID = $user->ID; wp_set_current_user( $userID, $user_login ); wp_set_auth_cookie( $userID, true, false ); do_action( 'wp_login', $user_login ); } } add_action( 'after_setup_theme', 'postCustomWPLogin' ); function MyForm() { if($_POST['srmsform_type'] == 'userLogin'){ postCustomWPLogin($_POST['username'], $_POST['password']); } $form_ret = ''; $form_ret .= '<p>Existing users, Please Login to enroll.<br> If you are registering for the first time, Please click "Register" below.</p>'; $form_ret .= "<form id='srmsform_userlogin' action='".str_replace( '%7E', '~', $_SERVER['REQUEST_URI'])."' method='post'>"; $form_ret .= '<input type="hidden" name="srmsform_type" value="userLogin">'; $form_ret .= "<label>User Name</br></label><input type='text' name='username' value='' id='username'></br>"; $form_ret .= "<br><label>Password</br></label><input type='password' name='password' value='' id='password'></br>"; $form_ret .= '<input type="hidden" name="instanceID" value="Some Values">'; $form_ret .= '<input type="hidden" name="courseType" value="Some Values">'; $form_ret .= "<br><input type='submit' id='enrolnow' class='course-button' value='Login'><br>"; $form_ret .= "</form>"; return $form_ret; } add_shortcode( 'My_form', 'MyForm' ); 

Когда я попытался войти в мою регистрационную форму в своем коротком кодексе, я получил эту ошибку:

 Warning: Cannot modify header information - headers already sent by (output started at /home/tidecoma/public_html/development/wp-content/themes/twentyfourteen/header.php:13) in /home/tidecoma/public_html/development/wp-includes/pluggable.php on line 918 Warning: Cannot modify header information - headers already sent by (output started at /home/tidecoma/public_html/development/wp-content/themes/twentyfourteen/header.php:13) in /home/tidecoma/public_html/development/wp-includes/pluggable.php on line 919 Warning: Cannot modify header information - headers already sent by (output started at /home/tidecoma/public_html/development/wp-content/themes/twentyfourteen/header.php:13) in /home/tidecoma/public_html/development/wp-includes/pluggable.php on line 920 Warning: Cannot modify header information - headers already sent by (output started at /home/tidecoma/public_html/development/wp-content/themes/twentyfourteen/header.php:13) in /home/tidecoma/public_html/development/wp-includes/pluggable.php on line 918 Warning: Cannot modify header information - headers already sent by (output started at /home/tidecoma/public_html/development/wp-content/themes/twentyfourteen/header.php:13) in /home/tidecoma/public_html/development/wp-includes/pluggable.php on line 919 Warning: Cannot modify header information - headers already sent by (output started at /home/tidecoma/public_html/development/wp-content/themes/twentyfourteen/header.php:13) in /home/tidecoma/public_html/development/wp-includes/pluggable.php on line 920 

кто-нибудь имеет представление о моем случае и как справиться с ним? заранее спасибо