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 … Read more