Search code examples
wordpressbuddypress

WordPress - Admin Spoof User Login


I am running BuddyPress and have recently imported users from another site; unfortunately the users are not showing up in BuddyPress as active. When using the plugin "User Switching", I am able to briefly log-in as any inactive user causing their profiles to then show up in BuddyPress.

How can I perform this action in bulk?


Solution

  • Try this in your theme/functions.php - remember to remove it after loading the site once:

    function prentiss_add_last_activity() {
        global $wpdb;
        foreach ( $wpdb->get_col( "SELECT ID FROM $wpdb->users" ) as $user_id ) {
            bp_update_user_last_activity( $user_id, bp_core_current_time() );
        }
    }
    add_action('bp_ready', 'prentiss_add_last_activity');