• Hi Max!

    Just installed Simple Login Log, great plugin!

    Ran into problem however… we’re installing it on a WP multisite (with many domain-based sub-blogs). Some of these blogs are also domain-mapped btw, however that should not make a difference.

    The problem is:

    1.) Logins to via the top-level site (mysite.com/wp-login.php) are logged to this table: wp_simple_login_log

    2.) However, logins to sub-sites in the same wordpress multisite install (i.e. bobsblog.mysite.com/wp-login.php), are logged into separately created tables for each sub-blog. i.e. for blog ID 92, they’re logged to this table: wp_92_simple_login_log

    This is problematic as a network administrator because I can’t see ALL of the logins in one place.
    It is also problematic because a new table is getting created for each network blog – this is 1000’s of unnecessary tables!

    Since users are created at the top level in WordPress, it makes sense that all of the logging would be stored at the top network level as well.

    Thoughts? Suggestions?

    Thanks!!
    Dan

    http://wordpress.org/extend/plugins/simple-login-log/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Max Chirkov

    (@maxchirkov)

    Hi Dan,

    I see the issue. Since I don’t have a multi-site setup, I don’t know what would be the best solution, off the top of my head. For now, you could simply hack the plugin by hardcoding the table name. Edit the PHP file – find this line within the constructor:

    $this->table = $wpdb->prefix . $this->table;

    and change the $wpdb->prefix to the prefix of your main table. For example:

    $this->table = 'wp_' . $this->table;

    this should work.

    Thread Starter Dan & Jennifer

    (@danstuff)

    Hey Max!

    Thanks for the helpful recommendation, that absolutely worked!

    Actually I added an if/then to check for multisite, with the is_multisite() function – see below.

    Would you consider adding this check to the production plugin code, that way we can update the plugin regularly when you release updates, without overwriting this fix. 🙂

    Thanks!!
    Dan

    // table where to log logins
    if ( is_multisite() )
        // hard-code table name for multisite only
        $this->table = 'wp_' . $this->table;
    else
        // non-multisite - regular table name
        $this->table = $wpdb->prefix . $this->table;
    Plugin Author Max Chirkov

    (@maxchirkov)

    Dan,

    yes, something like that would work, we just need to avoid any hard-coded prefixes, since WP allows to define custom prefixes during the installation. So, something like this would probably be better:

    if ( is_multisite() )
        // get main site's table prefix
        $main_prefix = $wpdb->get_blog_prefix(1);
        $this->table = $main_prefix . $this->table;
    else
        // non-multisite - regular table name
        $this->table = $wpdb->prefix . $this->table;

    Thread Starter Dan & Jennifer

    (@danstuff)

    @max looks great!

    Thanks!
    Dan

    Plugin Author Max Chirkov

    (@maxchirkov)

    Dan,

    Just FYI – the milti-site feature that we talked about above will not make it into the next update (v.0.9.4). You will need to make the same code alterations again (if you choose to update). Currently, I don’t have the ability to test the multi-site setup and I don’t know how this would function exactly… I don’t know if the plugin gets installed network-wide, and if so, do individual blog admins see the Login Log page under the Users as well as Login Log settings under General Settings? If so, then in case like yours they shouldn’t – only Network Admin should be able to see those things… I have to have a multi-site development setup, before I can implement this correctly and commit to a new version.

    Thread Starter Dan & Jennifer

    (@danstuff)

    Hey Max!

    Thanks for the update. I can definitely help u test it!

    Yes, the plugin would have to be network activated (as we’ve done( so that it would record logins at main multisite level AND at individual sub-site level.

    And you’re quite right… this is a security feature… so it’s for the network superadmin – so it should be listed in the primary site Users->Login Log but not in the other sites.

    You know, that can be just a checkbox option in config…

    Also wanted to make sure you saw this post – it’s a continuation of the same thing. 🙂
    http://wordpress.org/support/topic/how-to-hide-users-login-log-sub-menu-for-sub-sites-in-multisite?replies=2

    Thanks!
    Dan

    Thread Starter Dan & Jennifer

    (@danstuff)

    Hey Max.

    I just updated the plugin, did a diff on the files, and tested.

    I can confirm the the new version ALREADY works great with multisite.

    the only change I had to apply was the one from this other support ticket:
    http://wordpress.org/support/topic/how-to-hide-users-login-log-sub-menu-for-sub-sites-in-multisite?replies=2

    Thanks!
    Dan

    Plugin Author Max Chirkov

    (@maxchirkov)

    Great to hear that, Dan! Thanks for letting me now.

    Do these updates mean that each site will see the logins for every other site on the network? That is not such a good idea. It would be better for each site to store the blog_id along with the login. Then in the Network Admin area a report can be generated for all or specific sites.

    Plugin Author Max Chirkov

    (@maxchirkov)

    Hi Ben,

    currently, each site should be displaying only its own log. Each site has a separate login-log table where its data is stored. Dan was offering a network option that would be only available to the network admin, and which allow oversee the logins for all sites on the network. In that case all site’s logins would be stored in a single table of the main site. This is not implemented into the plugin, but Dan is using code mentioned above in his own setup.

    Ok, thanks. I will see if I can hack something together that will do what I need

    Dan, would you be willing to test out what I have hacked together? It logs perfectly for Multisite, and wp-multi-network. Site owners only see logins to their site, network admins see logins for the entire network, the main multisite administrator sees logins across all networks and sites. If you are interested drop me a line at ben@lobaugh.net

    Thread Starter Dan & Jennifer

    (@danstuff)

    @ben, sorry just now saw this. 🙂

    Hmm, our config is different, we’re not looking for site admins to see their own site login history. this is more of a site-wide security thing to have an audit log of logins. So the existing code is working for us as is.

    Thanks!
    Dan

    Thread Starter Dan & Jennifer

    (@danstuff)

    @max just updated to the latest version, and looks like the Multisite code you recommended above has been incorporated – AND it works great.

    I’m very happy because I can now take this plugin off the list of “plugins we’ve made changes to so can’t readily update” LOL.

    Thanks!!!
    Dan

    Plugin Author Max Chirkov

    (@maxchirkov)

    You’re welcome, Dan. I released an update quite some time ago… can’t even remember what exactly I committed 🙂

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Issues with MultiSite – please help :-)’ is closed to new replies.