[Resolved] Favouriting behaves incorrectly when zero Job Ads are favourited
This support ticket is created 2 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
If possible, could this ticket be assigned to Jamal? He worked intensively with us to create our Favourites functionality and wrote the Custom Code snippet necessary to get it working.
We are seeing inconsistent behaviour in our Favourites Views, in particular My Favourite Job Ads View.
Related Custom Code Snippet: "favourites"
Related 3rd party plugin: "WP Favorite Posts"
Issue:
It works for some users, but not for others with the same role. Affected role: Native Nanny.
Correct behaviour:
1) Log in as {login info removed}
2) Click the heart symbol in the menu. Only Job Ads are shown which have been favourited (the favourite heart is solid green).
3) Favouriting more Job Ads under Find a Job continues to show only the favourited ads.
4) Removing all hearts under Find a Job correctly shows zero Job Ads when clicking the Favourites menu (heart symbol). Our customised message for No Ads to show is correcly displayed.
5) This seems to work correctly, regardless of which language the Job Ad was favourited in.
Incorrect behaviour:
1) Log in as {login info removed}:
2) Click the heart symbol in the menu. ALL Job Ads are shown even when no Job Ads have been favourited (although the favourite heart is showing as an empty heart, ie is unfavourited).
3) Favouriting one or more Job Ads under Find a Job shows only the favourited Job Ads.
4) Removing all hearts under Find a Job incorrectly shows ALL Job Ads when clicking the Favourites menu (heart symbol). Our customised message for No Ads to show is NOT displayed, instead ALL Job Ads are displayed.
5) The favouriting appears to be working correctly, regardless of which language the Job Ad was favourited in.
The incorrect behaviour appears to be happening only when zero Job Ads are favourited.
We'd greatly appreciate your help getting this working consistently for all users.
Jamal has moved to a different department, so it won't be possible for him to follow up on this.
Looking into the code snippets in the custom code 'favourites', this is expected because when a user has no favorite posts, the "wpfp_get_user_meta()" function returns an empty array.
This change checks for the favorited posts through the "wpfp_get_user_meta()" function and if it is empty, sets the query to include only an imaginary post with ID '0', which in turn results in no items found message.