PHP code example of aiyuchen / wordpress-auth-provider
1. Go to this page and download the library: Download aiyuchen/wordpress-auth-provider library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aiyuchen / wordpress-auth-provider example snippets
Auth::guard('wordpress')->loginUsingId(5);
// or login using email and password
Auth::guard('wordpress')->attempt([
'user_email' => '[email protected]',
'user_pass' => 'quickbrownfox'
]);
// get user object
Auth::guard('wordpress')->user();
// Update wordpress compatible password
$user->user_pass = app('wordpress-auth')->make('new_password');
$user->save();
// logout
Auth::guard('wordpress')->logout();
Auth::loginUsingId(5);
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return \Password::broker('wordpress');
}
/**
* Get the guard to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\StatefulGuard
*/
protected function guard()
{
return \Auth::guard('wordpress');
}