-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add README file, add serialization/unserialization of meta values, ad…
…d setUserMeta, add timeout on cached data
- Loading branch information
1 parent
19a2618
commit 7853def
Showing
3 changed files
with
610 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
TO INSTALL: | ||
=========== | ||
npm install mysql-native | ||
|
||
TO USE: | ||
======= | ||
In your init: | ||
var wp_auth = require('wp-auth').create( 'http://my-blog.example', | ||
'LOGGED_IN_KEY from wp-config.php', | ||
'LOGGED_IN_SALT from wp-config.php', | ||
'MySQL host', | ||
'MySQL username', | ||
'MySQL password', | ||
'MySQL database', | ||
'WordPress table prefix (eg. wp_)' ); | ||
|
||
When you get a HTTP request and you need to verify auth: | ||
wp_auth.checkAuth( req ).on( 'auth', function( auth_is_valid, user_id ) { | ||
auth_is_valid; // true if the user is logged in, false if they are not | ||
user_id; // the ID number of the user or 0 if the user is not logged in | ||
} ); | ||
|
||
To get a usermeta value: | ||
wp_auth.getUserMeta( user_id, 'meta_key (eg. occupation)', function( data ) { | ||
// data is null if the user doesn't exist or doesn't have the key. | ||
// Otherwise, it is the value you would get in WordPress (unserialized intelligently) | ||
} ); | ||
|
||
To set a usermeta value: | ||
wp_auth.setUserMeta( user_id, 'meta_key (eg. occupation)', 'meta_value (eg. Eating spaghetti)' ); |
Oops, something went wrong.