Add Login Form Anywhere in WordPress Template
For the convenience of your subscribers on the site, it would be nice to give them the opportunity to log in from any page of the site, not follow the link www.sitename.ru/wp-admin. To add a login form anywhere on the site, you can use the function wp_login_form().
For the function, you can set additional settings for the form operation in the form of an array of arguments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php $args = array( 'echo' => true, 'redirect' => 'https://wpsnipp.com', 'form_id' => 'loginform', 'label_username' => __( 'Username' ), 'label_password' => __( 'Password' ), 'label_remember' => __( 'Remember Me' ), 'label_log_in' => __( 'Log In' ), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => NULL, 'value_remember' => false ); wp_login_form($args); ?> |
Checked the code, works. I did not check all the arguments, but I think there will be no problems. Good luck in website development.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.