Get ids of liked posts from database

I'm using Buddypress with Buddypress like plugin and I want to get ids of all posts liked by a logged in user. There is a row in a database called bp_liked_blogposts with an array as a value. The row looks like this:

row screenshot

I tried to display this field using get_user_meta function and then implode the array with PHP to list of values. The result was "blogpost_liked","blogpost_liked"... but I need to get the number that goes after i:

I'm not PHP or Mysql expert so I need some help with this. Thank you.


You don't need to manually explode that data. The data is stored in JSON format. You can use json_decode to automatically construct an array out of your data.

Tags: PHP / Mysql / Database

Similar questions

Mysql Query order by most liked
i am trying to run a mysql query to order by most liked. this is my select statment. But what i need to do is order by most liked which would be fine if it was just a number in the field ie. But here is what i get in the fields??? How can i order by the a:2 value ???? This worked
Wordpress Social Locker locks content even if user already liked page
I installed OnePress Social Blocker plugin to my Wordpress website. I set up everything correctly according to documentation. When user likes Facebook page, content is shown. But right after I refresh my page content is blocked again and user must click on Unlike button and then click again on Like button to reveal content, which is not very user f...
Unlock content of other users in response to the owner's fb page is liked
I run a Wordpress website. I have many users who have content of their own. I want to add this feature: if one user wants to see another user's content, then the user (who wants to see) has to Like the other user's Facebook page. Is there any plugin to do this? I am currently using this code by Patrik from Stack Overflow: But I actually need to als...
Social PopUP - Facebook like. Not showing popup if the user has already liked
Is there any way to implement not showing the popup (for Facebook) if the user has already liked the page? Currently in that case the popup is still shown, only with the grayed out "like" button.
Showing most liked post within the past week
I've run into an interesting issue while trying to display most liked posts over the past week. Here's the desired process: Editor posts a new article and users can come in and "like" the post. I want the "most liked" posts over the past week show at the top of the feed. This functionality works great right now, however, after 4-5 days these posts ...
Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
I have a code which sorts the content by most liked, but I would like it to show the most liked in between previous week monday and next week monday. And the posts must be published in that time frame. Tho I have no idea how to sort by published date and most liked in that time frame. Grateful for help if anyone can.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.