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:
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.
Solutions
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.
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...
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 ...
Also ask