The Library requires two things:
- A DB Connection to Wordpress (usually found in wp-settings.php)
- (optionally) a Dean token to manage connection between WP_Account and Dean_Account
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);
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
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":[]
}
}
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
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)
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)
public function getWPUser($wp_id){
#...
}
Params:
$wp_id - ID in WP
Returns:
Same response as "login method"