[Plugin: WP Favorite Posts] major bug getting user favourites?
-
Hi,
Just noticed this while testing. Here’s how I reproduce.
1. Change the plugin setting to allow non-logged-in users to save favourites.
2. Log out, favourite a post without logging in. This will create a cookie.
3. Log in, go to the page with your favourites.I get favourites listed from the non-logged-in user cookie alongside with the logged-in user stuff. Or, if the logged-in user had zero, they now have favourites listed from the cookie.
Here’s the code in question (wp-favorite-posts.php:173):
if (is_user_logged_in()): $favorite_post_ids = wpfp_get_user_meta(); endif; if (wpfp_get_cookie()): foreach (wpfp_get_cookie() as $post_id => $post_title) { array_push($favorite_post_ids, $post_id); } endif;
Seems like the code will get favourites from the database first, then push all the favourites from the cookie onto the same array. Here’s my quick dirty fix:
if (is_user_logged_in()): $favorite_post_ids = wpfp_get_user_meta(); else: if(wpfp_get_cookie()): foreach (wpfp_get_cookie() as $post_id => $post_title) { array_push($favorite_post_ids, $post_id); } endif; endif;
- The topic ‘[Plugin: WP Favorite Posts] major bug getting user favourites?’ is closed to new replies.