Skip to content

A Small library for authenticating users on WordPress and Connecting their ID to a Dean_Account

Notifications You must be signed in to change notification settings

flexlex/XWPDean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Killo_XWPAuth

Killo eXternal WordPress Authentication

Introduction

The Library requires two things:

  1. A DB Connection to Wordpress (usually found in wp-settings.php)
  2. (optionally) a Dean token to manage connection between WP_Account and Dean_Account

Usage

Some examples

include("dbdata.php"); //LOAD DB CONFIG
require_once("killo_wp_auth/x_wp_auth.php"); //INCLUDE LIBRARY
$xwp = new Killo_XWPAuth();
$xwp->deanToken = "K2QIWKWI400II6KS7LDC"; #Settings the Dean Token

//USAGE ESAMPLES

# $r = $xwp->login("email","pass");
# $r = $xwp->localAssign(1,1);
# $r = $xwp->createDeanStudent(["nome"=>"Name","cognome"=>"Surname","bday"=>"2000-01-01"]);
# $r = $xwp->getDeanStudent(1);
# $r = $xwp->getWPUser(1);

Methods

Constructor

function __construct($db_host = DB_HOST, $db_name = DB_NAME, $db_user = DB_USER, $db_pass = DB_PASSWORD, $db_port = 3306,$dean_token=DEAN_TOKEN,$dean_endpoint = "https://killo.software/api/"){
#...    
}

The library will look for the default WP Contstants for DB Access, you can override them by using the parameters.

Params:

$db_host - The host for the Mysql DB $db_name - The DBName in the Mysql DB $db_user - The username for the Mysql DB $db_pass - The password for that Mysql User $db_port - The port of the DB (default: 3306) $dean_token - The token to access your license api $dean_endpoint - The url to the Dean api (default: https://killo.software/api)

Returns:

instance

login

public function login($email,$pass){
    #...
}

Params:

$email - The email of the WP_user $pass - The password of the WP_user

Returns:

Object

{
    "success":true,
    "wp_id":1,
    "wp_data":{
        "user_login":"username",
        "user_pass":"hash",
        "user_mail":"user mail",
    },
    "dean_id":1,
    "dean_data":{
            "id":" 1",
            "nome":" ",
            "cognome":" ",
            "bday":"2000-01-01T00:00:00.000Z",
            "age":20,
            "sesso_id":" ",
            "sesso_nome":" ",
            "nazionalita_id":" ",
            "nazionalita_nome":" ",
            "indirizzo":" ",
            "indirizzo_civico":" ",
            "indirizzo_cap":" ",
            "indirizzo_city":" ",
            "indirizzo_codnaz":" ",
            "attivo":0,
            "cidentita":" ",
            "passaporto":" ",
            "passaporto_scadenza":" ",
            "passaporto_rilascio":" ",
            "passaporto_autorita":" ",
            "email":" ",
            "cell":" ",
            "tel":" ",
            "livello_suggerito_id":" ",
            "livello_suggerito_nome":" ",
            "intolleranza":" ",
            "created":"2020-04-24T00:42:15.000Z",
            "occupazione_id":0,
            "codf":" ",
            "piva":" ",
            "preferenza_alloggio":" ",
            "newsletter":0,
            "datapolicy":1,
            "photoandvideo":0,
            "minor_agree":0,
            "minor_exit":0,
            "minor_noactivity":0,
            "acquisti":[],
            "timeOffset":-120,
            "metadata":[]
    }
}

localAssign

public function localAssign($wp_id,$dean_id){
    #...
}

Assign student in WP to a Student in Dean

Params:

$wp_id - ID in WP $dean_id - ID in Dean

Returns:

PDO Insert statement response

createDeanStudent

public function createDeanStudent($data,$wp_id){
    #...
}

Params:

$data - Data for creating a student in dean (refer to: https://killo.software/apidocs/#WStudenti) $wp_id - ID in WP (will be assigned to the newly created student)

Returns:

Dean Api response to create Student
(refer to: https://killo.software/apidocs/#WStudenti)

getDeanStudent

public function getDeanStudent($dean_id){
    #...
}

Params:

$dean_id - ID in Dean

Returns:

Dean Api response to get Student Data
(refer to: https://killo.software/apidocs/#RStudentiItem)

getWPUser

public function getWPUser($wp_id){
    #...
}

Params:

$wp_id - ID in WP

Returns:
Same response as "login method"

About

A Small library for authenticating users on WordPress and Connecting their ID to a Dean_Account

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published