Peer-reviewed code snippets that anyone can edit
follow refactory on twitter
blog
feedback
A wiki for useful code snippets
Bugs? Suggestions?
38-107-191-111
create/login
options
RECENT
STUBS/REQUESTS
STARRED
ACTIVITY
ADD
VIEW
EDIT
FORK
WordPress Plugin Authenticates User
php
wordpress
plugin
authenticate
user
auto-login
login
Your work won't be attributed to you
because you aren't logged in.
Login using OpenID or an existing username, or create a username
(no email required) before posting.
Languages
Comma separated. Like
ruby, rails
or
java, swing
Keywords
Comma separated. Like
file, network
Mark as stub
Snippet
Wrap code in
[code=
language
][/code]
- Use
WikiText markup
outside of [code] tags
[code=php] function authenticate( $user_id, $user_name, $user_pass ) { global $current_user; $current_user = WP_User( $user_id ); $return = wp_login( $user_name, $user_pass ); if ( $return ) $return = wp_set_cookie( $user_name, $user_pass ); else return new WP_Error( 'Something went wrong while logging in!' ); if ( $return ) return true; else return new WP_Error( 'Something went wrong while setting a cookie!' ); } [/code]
Log message
Human?
public snippets
This is a community-maintained collection of reusable code snippets.
Contribute something
without logging in, or improve existing contributions. All code is dedicated to the public domain unless otherwise specified.
stats
/
top contributers