I already figured it out using this query:
<?php
global wpdb;
$be_user = $current_user->ID;
$get_user_saved_events = $wpdb->get_results(‘SELECT * FROM ‘.$wpdb->prefix.’ulike WHERE user_id = ‘.$be_user.’ AND status = “like”‘ );
foreach ($get_user_saved_events as $get_user_saved_event) {
//loop here
}
?>
Hope this helps!
Dude, how did you implement it? To class-widget.php? This is so close to what i’m looking for and i can get it to echo the user id and posts with ‘like’ relative to the id but holy moly is it hard to find a way for it to actually fetch post.
hi @skiezis,
sorry for the late reply.
I put the code on the author.php template.
So for the loop part you just start by putting :
//loop here
<h1><?php the_title ?></h1>
and it will list all the post that the user liked. Be sure to change the query_results statement, with $be_user used to get the current user ID.
Hey @varrowyn no problem, thanks for replying!
I figured it out with the widget. I had to fetch post title and image with it and i used your query to modify it.
$likes = $wpdb->get_results( "
SELECT U.post_id, P.meta_value AS counter, U.status, T.ID, T.post_content
FROM ".$wpdb->prefix."ulike AS U,
$wpdb->postmeta AS P, $wpdb->posts AS T
WHERE U.user_id = $user_ID AND U.post_id = T.ID
AND U.post_id = P.post_id AND U.status = 'like'
GROUP BY U.post_id
ORDER BY MAX(U.date_time) DESC LIMIT $numberOf
" );
if( $likes !== 0 ){
foreach ($likes as $like) {
//Then just modified the results to catch what i need here, for example:
$image_large=upg_image_src('large',$like);
//(using user post gallery plugin as well, that's where upg comes from)
}
So, now i have a widget which shows users liked images.
Thanks!