I'm using this php script that is supposed to update bp members last activity status to current time but I'm getting a HTTP 500 error. What am I doing wrong?
<?php
// Include WordPress bootstrap
define('WP_USE_THEMES', false);
require('path_to_wordpress_installation/wp-blog-header.php');
// Function to randomly update last_activity for 150 BuddyPress members with a specific role
function update_random_members_last_activity($role) {
$users = get_users(array(
'role' => $role,
'number' => 150, // Limit the number of users to 150
'orderby' => 'rand', // Order randomly
));
foreach ($users as $user) {
bp_update_user_last_activity($user->ID);
// Optionally, perform other tasks with each user here
echo "Updated last activity for user: " . $user->display_name . "<br>";
}
}
// Call the function with the desired role
$role = 'your_role'; // Replace 'your_role' with the actual role
update_random_members_last_activity($role);
?>
I was expecting 150 members' last activity status to be randomly updated based on their role.