Wordpress. Authorization with wordpress API

Home » Tutorials » CMS » WordPress. Authorization with wordpress API
Today we will begin to create another project with using Woocommerce API, AngularJS and AngularJS Material. Today we will create the page with authorization form.
wp_signon will check login and password correctness

Code lesson (index.php)


$error = null;

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: manager');
		$error = null;


<!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8">
	<link rel="stylesheet" href="https://bootswatch.com/4/materia/bootstrap.css">

	<div class="container">
		<div class="row">
			<div class="col-sm-12">
				<form method="post">
					<fieldset class="mb-2">
						<div class="form-group">
							<label for="login">Логин</label>
							<input type="text" class="form-control" id="login" name="login" placeholder="Логин">
						<div class="form-group">
							<label for="login">Пароль</label>
							<input type="password" class="form-control" id="password" name="password" placeholder="Пароль">
						<button type="submit" class="btn btn-primary">Вход</button>
					<?php if ($error) { ?>
						<div class="alert alert-dismissible alert-danger">
							<button type="button" class="close" data-dismiss="alert">×</button>
							<?php echo $error; ?>
					<?php } ?>


Submit a Comment

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.

Pin It on Pinterest

Share This