WordPress.org

Ready to get started?Download WordPress

Forums

Wp_login Action Hook Doesn't Work in Network Mode? (7 posts)

  1. b-rad
    Member
    Posted 3 years ago #

    I'm tinkering with writing a plugin and when I run it on a single blog WordPress site, the wp_login action hook works great. In my function I can get the user name of the logged in user in my function with global $user_name;. However when I try the same code on a WordPress multi user/network install, I get nothing for the user name. Not even for the admin. Not being sure if it was the wp_login hook or my function that it should call, I also tried getting the username via global $current_user; get_currentuserinfo(); and then using $current_user->user_login but that still gives me nothing. What's adding to my confusion is that I also tested using wp_logout in multi user/network mode and global $current_user; get_currentuserinfo(); with $current_user->user_login works.

    So is this a mu/network bug with the wp_login action hook, or am I missing something?

  2. Curtiss Grymala
    Member
    Posted 3 years ago #

    Are you activating the plug-in in exactly the same way (i.e. uploading it to your /wp-content/plugins/ directory, then clicking the "Activate" link in the plugin administration area) on both installations?

    Into which action(s), if any, are you hooking your function?

  3. Not all plugins will (and can) work when activated sitewide.

    Did you try activating it PER site? If that works, it may be because of how it creates tables and functions per site.

  4. b-rad
    Member
    Posted 3 years ago #

    I'm only activating it as admin and not for everyone who has an account. I don't want the users to see the plugin or be able to delete or deactivate it. Are there no hooks for admin use that will activate for every wordpress user?

  5. Well, you could try using mu-plugins.

    Read this: http://wpmututorials.com/basics/what-is-the-mu-plugins-folder/

  6. Are there no hooks for admin use that will activate for every wordpress user?

    There's the mu-plugins folder for code you want to run all the time and not be disabled.
    http://wpmututorials.com/basics/what-is-the-mu-plugins-folder/

    the login/logout that is in themes works exactly the same when the network is enabled. Not sure what you;re doing though.

  7. b-rad
    Member
    Posted 3 years ago #

    Thanks Ipstenu and Andrea_r, I'll check that out. Wasn't aware of it.

Topic Closed

This topic has been closed to new replies.

About this Topic