enricodeleo/wp-client-ajax-login

A simple plugin that allows login to wordpress through the client's browser via AJAX.

Fund package maintenance!
Patreon

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Language:Shell

Type:wordpress-plugin

0.1.8 2015-05-04 00:45 UTC

This package is not auto-updated.

Last update: 2024-04-23 01:14:16 UTC


README

A simple helper plugin that allows login to wordpress through the client's browser via AJAX.

How to install

Composer

If you're using Composer to manage your codebase add this plugin to your dependencies running:

composer require enricodeleo/wp-client-ajax-login 0.1.8

Or manually add it to your composer.json:

"require": {
  "enricodeleo/wp-client-ajax-login": "0.1.8"
}

Legacy way

Download this repo as a zip file and extract it to your wp-content/plugins directory.

OR

Install this plugin via the official Wordpress Plugin registry https://wordpress.org/plugins/wp-client-ajax-login/admin/.

Usage

This plugin is an helper and doesn't add anything to your wordpress theme. You might want to use it in conjunction with your frontend custom code.

You can use vanilla Javascript, Angular, or any framework that suits your needs.

Here's an example with jQuery:

$.ajax({
    type: "POST",
    url: "http://yoursite.dev/wp-admin/admin-ajax.php", //change this url acoording to your wp site
    xhrFields: {
        withCredentials: true
    },
    data: {
        user: "username", //hard-coded for example purposes
        pwd: "password", //hard-coded for example purposes
        action: "clientAjaxLogin"
    },
    success: function(resp) {
        var respObj = JSON.parse( resp );
        if( respObj.success ) {
            window.location = respObj.success;
        } else {
            console.log( respObj.error );
        }
    }
});

Of course you can bind the ajax call to an event like submitting a form.