Answer the question
In order to leave comments, you need to log in
How to make wordpress login without plugins?
I tried to implement authorization in wordpress without plugins by writing a script in header.php -
1 script:
<?php
require('wp-load.php');
$error = null;
$user = wp_signon();
if(!empty($_POST)) {
$creds = array();
$creds['user_login'] = strip_tags(trim($_POST['login']));
$creds['user_password'] = strip_tags(trim($_POST['password']));
$user = wp_signon($creds, false);
if($user->errors) {
$error = 'Неверный логин или пароль';
} else {
header('Location: http://airemont/');
$error = null;
}
}
?>
<?php if (!current_user_can('level_0')) { ?>
<script type="text/javascript">
function login_clear() {
var log = document.getElementById('log');
if (log.value == "Логин"){ log.value = "";}
}
function pwd_clear() {
var pwd = document.getElementById('pwd');
if (pwd.value == "Пароль"){ pwd.value = "";}
}
</script>
<div class="loginlabel" align="center">
<table width="885" border="0" cellspacing="0" cellpadding="7">
<tr>
<td align="left" bgcolor="#cccccc" height="30">
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post" >
<input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="20" />
<input type="password" name="pwd" id="pwd" size="20" value="" />
<input type="submit" name="submit" value=" Войти " class="button" />
<label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" value="forever" /> Запомнить</label>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword">Забыли пароль?</a>
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=register">Регистрация</a>
</form>
</td>
<td align="right" bgcolor="#CCCCCC" height="30"><?php get_search_form(); ?></td>
</tr>
</table>
</div>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question