• Resolved jkdev

    (@jkdev)


    Hello,

    Thanks you for the great plugin! I have a question I’m hoping you can help with..

    I have a multisite network, and wondering if there is a way to “Delete All Failed Login Records” from all the sites on the network at once, without having to go into each subsite. Just to be clear, I’m talking about the button under WP Security > User Login > Failed Login Records Tab. Hoping for a way to purge those for all subsites from one spot on the primary site, or network admin. Maybe a cron job, anything that could get it done really.

    I’m okay with adding some code to the functions.php if needed.

    Thank you

    • This topic was modified 5 years, 6 months ago by jkdev.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi, thank you for reaching out to us. I have submitted a message to the developers to investigate further your request.

    Kind regards

    Thread Starter jkdev

    (@jkdev)

    @mbrsolution Hello, just checking in on this. Thank you.

    Plugin Contributor wpsolutions

    (@wpsolutions)

    Hi @jkdev,

    “Delete All Failed Login Records” from all the sites on the network at once

    Short answer is no there isn’t.
    But there is a filter hook which controls how many rows are kept in the aiowps_failed_logins table. You could add some code in your functions.php file and set the number of rows to 0.
    The filter is defined inside the wp_security-backup.php file as follows:
    $max_rows_failed_logins_table = apply_filters( 'aiowps_max_rows_failed_logins_table', $max_rows_failed_logins_table );

    So you could hook into the above filter from your functions.php and return a value of 0 for the $max_rows_failed_logins_table.
    Your table rows will then get deleted when the aiowps hourly cron task eventually fires.

    ps: you could speed up the process and network deactivate and reactivate the aiowps plugin and then visit each of your subsite home pages to trigger the cleanup task.
    After you’ve cleaned up the tables you might want to comment out the code from your functions.php file if you don’t want that table to be continually emptied.

    Thread Starter jkdev

    (@jkdev)

    @wpsolutions Hello, thank you for the info. I tried to do this, and couldn’t get the hook to work. Do you think it would be possible for you to give me exactly what I need to add into the functions.php file?

    Thread Starter jkdev

    (@jkdev)

    Looks like I got it working. This is what I added to my functions.php. Does this look correct?

    function clear_security_failed_login() {
    
            $failed_logins_table_name = AIOWPSEC_TBL_FAILED_LOGINS;
            $max_rows_failed_logins_table = '10'; //Keep a max of 5000 rows in the events table
            $max_rows_failed_logins_table = apply_filters( 'aiowps_max_rows_failed_logins_table', $max_rows_failed_logins_table );
            AIOWPSecurity_Utility::cleanup_table($failed_logins_table_name, $max_rows_failed_logins_table);
    
    }
    
    add_action('aiowps_perform_db_cleanup_tasks', 'clear_security_failed_login');
    • This reply was modified 5 years, 5 months ago by jkdev.
    Plugin Contributor wpsolutions

    (@wpsolutions)

    Hi @jkdev,
    It’s not quite right in the sense that you are not hooking into the “filter” I mentioned earlier, but you are hooking into an action hook. So I guess it is an alternative way to clear out that table.

    However I recommend that you use the filter I mentioned earlier.
    You will need to use the “add_filter” function because you are hooking into a filter not an action hook.
    Here’s an example which will clear all rows except 5:

    add_filter('aiowps_max_rows_failed_logins_table', 'modify_max_rows_failed_logins', 10, 1);
    function modify_max_rows_failed_logins($max_rows) {
    	return 5;
    }
    Plugin Contributor mbrsolution

    (@mbrsolution)

    @jkdev, did the solution provided by wpsolutions helped you in any way?

    Thank you

    Thread Starter jkdev

    (@jkdev)

    @wpsolutions @mbrsolution I was just able to test it out and it works perfectly. Much better than what I had. Thanks for the help!!!

    Plugin Contributor mbrsolution

    (@mbrsolution)

    I am happy to know ??

    Enjoy the plugin.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Delete Failed Logins – Multisite’ is closed to new replies.