• I really like this plugin because of the analytics it give from the admin’s side.

    So I’ve read all 26 pages of the forum, but somehow I couldn’t get the write function to show a user’s liked posts in a page (e.g. author.php).

    I was able to checked the database but there is no user meta_key of _like. There is one from post meta_key which is _liked, though.

    With those information at hand, how do I please get to show the user’s liked posts on a page?

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter varrowyn

    (@varrowyn)

    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.

    Thread Starter varrowyn

    (@varrowyn)

    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!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘User’s Liked Post’ is closed to new replies.