I am working on custom login page for WordPress, but I have problem. After I click on submit button I got the following error:
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\wordpress-4.7.3\wp-includes\class.wp-styles.php:237) in C:\wamp\www\wordpress-4.7.3\wp-includes\pluggable.php on line 904 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\wordpress-4.7.3\wp-includes\class.wp-styles.php:237) in C:\wamp\www\wordpress-4.7.3\wp-includes\pluggable.php on line 905 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\wordpress-4.7.3\wp-includes\class.wp-styles.php:237) in C:\wamp\www\wordpress-4.7.3\wp-includes\pluggable.php on line 906 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\wordpress-4.7.3\wp-includes\class.wp-styles.php:237) in C:\wamp\www\wordpress-4.7.3\wp-includes\pluggable.php on line 1195
Here is my custom login full codes
<?php
function dlf_form() {
echo '
<form class="form-inline" method="post" action="' . $_SERVER['REQUEST_URI'] . '">
<div class="form-group">
<input type="text" id="email" name="login_name" placeholder="إسم المستخدم">
</div>
<div class="form-group">
<input type="password" id="pwd" name="login_password" placeholder="كلمة السر">
</div>
<button type="submit" name="dlf_submit">تسجيل</button>
</form>
';
}
function dlf_auth( $username, $password ) {
global $user;
$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();
}
if ( !is_wp_error($user) ) {
wp_redirect(home_url('wp-admin'));
}
}
function dlf_process() {
if (isset($_POST['dlf_submit'])) {
dlf_auth($_POST['login_name'], $_POST['login_password']);
echo 'Test text';
}
dlf_form();
}
function dlf_shortcode() {
ob_start();
dlf_process();
return ob_get_clean();
}
add_shortcode('dm_login_form', 'dlf_shortcode');