public function OnBuddyPressUserUpdate($user_id = 0)
 {
     if (0 == $user_id) {
         // Get the current user
         $user = wp_get_current_user();
     } else {
         $user = get_userdata($user_id);
     }
     // Pass their ID to the function that does the work.
     AC_OnUpdateUser($user->ID, $user, TRUE);
 }
Exemple #2
0
function AC_OnRunSyncUsers()
{
    $numSuccess = 0;
    $numFailed = 0;
    $summary = '<strong>Report: </strong>';
    // Get a list of users on this site.  For more, see:
    // http://codex.wordpress.org/Function_Reference/get_users
    $users = get_users('');
    $numUsers = count($users);
    // Iterate over the array and retrieve that users' basic information.  The
    // info is written to the DB so that the client can periodically make ajax
    // calls to learn the progress.
    foreach ($users as $user) {
        $result = AC_OnUpdateUser($user->ID, $user, FALSE);
        if (0 === $result) {
            $numSuccess++;
            $message = "<br>Successfully synchronized: {$user->user_email}";
            update_option(WP88_MC_MANUAL_SYNC_STATUS, $message);
        } else {
            $numFailed++;
            $message = "<br>Failed to sync email: {$user->user_email}, Error: {$result}";
            update_option(WP88_MC_MANUAL_SYNC_STATUS, $message);
            $summary .= $message;
        }
        $percent = intval(($numFailed + $numSuccess) / $numUsers * 100);
        update_option(WP88_MC_MANUAL_SYNC_PROGRESS, $percent);
    }
    if (0 == $numFailed) {
        $summary .= '<br/>All ';
    } else {
        $summary .= '</br>';
    }
    $summary .= $numSuccess . ' profiles were <strong>successfully</strong> synced.</div>';
    echo $summary;
    // Clean out the records
    delete_option(WP88_MC_MANUAL_SYNC_STATUS);
    delete_option(WP88_MC_MANUAL_SYNC_PROGRESS);
    exit;
    // This is required by WordPress to return the proper result
}