link variable to user

To expound on Chris’ answer, the AJAX call would look something like this in your functions.php file:

add_action('wp_ajax_add_favorite', 'add_favorite');

function add_favorite(){
    $post_id = $_POST['postID'];
    $nonce = $_POST['nonce'];
    if(!wp_verify_nonce($nonce, 'wpnonce'))
        exit;

    if($post_id):
        $favorites = get_user_meta(get_current_user_id(), 'favorites');
        if(in_array($post_id, $favorites)):
            $response="Already in favorites.";
            $success = false;
        else:
            if(add_user_meta(get_current_user_id(), 'favorites', $post_id, false)):
                $response = "This post was added to your favorites";
                $success = true;
            endif;
        endif;
    else:
        $success = false;
        $response = "No post ID was supplied";
    endif;

    $output = json_encode(array('success'=>$success, 'response'=>$response));
    echo $output;
    exit;
}

The jQuery AJAX request would look like this:

jQuery('.add-to-favorites').click(function(){

    var data = {
        action: 'add_favorite',
        nonce: jQuery('#_wpnonce').val(),
        postID: jQuery(this).attr('rel')
    };

    jQuery.post(ajaxurl, data, function(output) {
        var obj = jQuery.parseJSON(output);
        if(!obj.response) alert('Something went wrong with the server.');

        if(obj.success){
            //Do Something Here
            alert(obj.response);
        }
        else{
            alert(obj.response);
        }
    });

    //Disable Click Through
    return false;
});

Your link on the front-end would look like this:

<a class="add-to-favorites' rel="<?php echo $post->ID;?>" href="#">Add To Favorites</a>

Add a hidden nonce field to the called ‘wpnonce’ and this should work just dandy. Also, make sure you define ajaxurl on the frontend so the script knows where to send the request.

You will need to do some reverse engineering in another PHP AJAX function to remove from favorites though. Hope this helps you out.