• elamine619

    (@elamine619)


    Hi, thank you for such a great plugin

    Is there a shortcode to list all the posts liked by a user inside eache user profile tab

    i am using Youzer (buddypress based) plugin and i need to make a profile tab (using shortcode) that shows the posts liked by the user whom the profile is opened .

    Thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • I would like to know about this too!

    Thanks!

    JH

    I’m also interested! The plugin will be so much usefull

    hi, Here is my “coding” way for get user liked post by user on author page.
    wpulike use a custom table that store the data. so i get an array of post_id liked by a specific user_id

    like that in my author.php :

    global $wpdb;
    $array_liked_post = $wpdb->get_results( “SELECT post_id
    FROM “.$wpdb->prefix.”ulike
    WHERE user_id = ‘$author_id’
    AND status = ‘like'”
    );
    // convert object result to an array of post_id
    $array_liked_post = array_map(function($oObject){
    $aConverted = get_object_vars($oObject);
    return $aConverted[‘post_id’];
    }, $array_liked_post);

    after you can make a wordpress query with ‘post__in’ => $array_liked_post
    That will give you the post liked by the user

    $args = array(
    ‘post_type’ => ‘post’,
    ‘post__in’ => $array_liked_post,
    ‘post_status’ => ‘publish’,
    );

    with that can make a shorcode or a function . Hope can help..

    Hi @benjaminnief, that seems to be awesome!

    How can we add that as shortcode to place in a buddypress single profile tab?

    Hi, imborx . my post is just an example. for your shortcode that depend if you want only a basic list, or if you want a list with post thumbnail of post and pagination etc.. Also i think buddypress/wpulike use different user id that wordpress user. so need check how to get user id from buddypress. The way is the same but i not have a predefined answer for your shortcode.

    Plugin Author Alimir

    (@alimir)

    Hi @benjaminnief @imborx
    If you are using the latest version (Currently V4.2.1). You can try the following function:

    $args = array(
        'type'     => 'post', //posts, comment, activity, topic
        'period'   => 'all',
        'order'    => 'DESC',
        'status'   => 'like',
        'page'     => 1,
        'per_page' => 10
    );
    $data = wp_ulike_get_user_data( $user_ID, $args );

    hi thank for reply Alimir..i think some people need a shortcode for this very good plugin..display user like..

    Thanks @alimir, really appreciate it.

    Unfortunately I’m not good with code to use integrate the function and show the user likes in buddypress as I want.

    Would be AWESOME if you could add integration with buddypress or at least make it works with a shortcode as benjaminnief says.

    As you can see with this post, we are a lot of WP Ulike users interested ??

    Best regards

    Plugin Author Alimir

    (@alimir)

    Hi @imborx @benjaminnief
    Creating a shortcode is easy, but the point is that it has a number of specific parameters for pagination, and more importantly, its output is an object that must be informed using functions such as get_the_title or some other desired functions in your custom html structure. I can create a general mode, but it won’t be very customize.

    Good afternoon. I’m trying to show list of the news (posts) that the user liked.
    In function.php create shortcode [greeting_ini]:
    function wpb_shortcode_likes() {
    $args = array(
    ‘type’ => ‘post’,
    ‘period’ => ‘all’,
    ‘order’ => ‘DESC’,
    ‘status’ => ‘like’,
    ‘page’ => 1,
    ‘per_page’ => 10
    );
    $data = wp_ulike_get_user_data( $user_ID, $args );
    }
    add_shortcode(‘greeting_ini’, ‘wpb_shortcode_likes’);

    But it doesn’t display anything.

    Plugin Author Alimir

    (@alimir)

    Hi @zorialive
    As I mentioned in the previous comment, this function’s output is an object that must be informed using functions such as get_the_title or some other desired functions in your custom html structure.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘user profile liked posts’ is closed to new replies.