Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am writing a plugin that fetches some extended user info from a remote service and I need it to execute its function each time a user logs in.

Is there a hook that gets fired after login that I can add an action to?

share|improve this question

2 Answers

up vote 7 down vote accepted

The action hook wp_login runs when the user logs in - it can run a simple function.

function do_anything() {
    //do stuff
}
add_action('wp_login', 'do_anything');

The real breadwinner here is wp_authenticate which has a bit of documentation. It passes an array with the given username and password, which gives you the opportunity to pass info to the remote service, if necessary.

http://codex.wordpress.org/Plugin_API/Action_Reference/wp_authenticate

share|improve this answer
no this runs when user clicks on login but before user gets verified. is there any hook that runs after user login and authentication success?????? – user13690 Feb 29 '12 at 21:06
whoopsie... I'll check and update the answer. – Drew Gourley Feb 29 '12 at 23:00
Checked, wp_login does run after authentication. What specifically do you need done? – Drew Gourley Feb 29 '12 at 23:07
wp_authenticate was what I was looking for. Thanks! – Adam Franco May 24 '12 at 19:35

I would caution against using wp_login. It is depreciated and in later versions of wordpress it may not work at all. Instead try, wp_sigon.

Word

share|improve this answer

protected by toscho Aug 1 '12 at 21:01

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.