Hook for when user logs into admin area. (2 posts)

  1. s1ngular1ty
    Posted 3 years ago #

    I'm looking for a hook that will run once and once only when someone logs into the admin area. However I do not want the hook to run, after the intial login, when a new page within the admin area is loaded.

    From the description I thought admin_init should work like this:

    admin_init is triggered before any other hook when a user access the admin area.

    However in the implementation I have shown below, my plugin options are being updated everytime a new page loads in the admin area.

    add_action( 'admin_init', 'zmb_plugin_admin_init' );
    function zmb_plugin_admin_init() {
      update_option('zmbShownSalesFrom','2013-01-01' );
      update_option('zmbShownSalesTo',  date('Y-m-d'));

    Can someone suggest a way to have these options update only on the intial login?

  2. bcworkz
    Posted 3 years ago #

    Perhaps use the 'wp-login' action, then confirm the user is an admin before updating the options?

Topic Closed

This topic has been closed to new replies.

About this Topic