Forums

Rating Badge - GD Star (6 posts)

  1. iperez_genius
    Member
    Posted 2 years ago #

    After much toiling (hard work) i have worked out that

    wp_gdsr_rating_multi(1,$post->ID);

    will return the results record from the DB that i need to build my rating badge.

    What i can't work out is how to get the value of 1 field from the above function.

    can someone advise

  2. Milan Petrovic
    Member
    Posted 2 years ago #

    Well, this is basic PHP. Function returns object, and you can access each property. Use print_r to preview the object and see properties.

  3. iperez_genius
    Member
    Posted 2 years ago #

    I have tried many things...

    echo $post->ID; //to prove that the id is actually 20
    $test =  wp_gdsr_rating_multi(1,$post->ID);
    var_dump(wp_gdsr_rating_multi(1,20));
    print_r(wp_gdsr_rating_multi(1,20));
    print_r(wp_gdsr_rating_multi(1,$post->ID));
    print_r($test);
    
    $test2 =  wp_gdsr_rating_multi(1,0);
    print_r(wp_gdsr_rating_multi(1,0));
    var_dump(wp_gdsr_rating_multi(1,0));
    print_r($test2);

    none of these lines print anything except for var_dump(wp_gdsr_rating_multi(1,20)); and var_dump(wp_gdsr_rating_multi(1,0)); which print NULL.

    i imagine either there is something wrong with my code or i am not using the function properly...

    anyone

    Ilan

  4. Milan Petrovic
    Member
    Posted 2 years ago #

    Than, your call is not valid. Either you don't have multi set with id 0, or there is no post with id 20, or there is no data recorded for this post for this set. This function works just fine, and I use it often, and it's used on TVScape.NET website among others.

  5. michal-drozd
    Member
    Posted 2 years ago #

    GD is unfortunately full of sloppy bugs

    look!!!:
    there is in data.php:

    function wp_gdsr_rating_multi($multi_set_id = 0, $post_id = 0) {
        if ($post_id == 0) {
            global $post;
            $post_id = $post->ID;
        }
    
        $multi_set_id = $multi_set_id == 0 ? gdsr_get_multi_set($post_id) : $multi_set_id;
        $multis_data = GDSRDBMulti::get_multi_rating_data($set_id, $post_id);
        if (count($multis_data) == 0) return null;
        return new GDSRArticleMultiRating($multis_data, $set_id);
    }

    do u see it ?
    wrong var name $set_id and should be $multi_set_id !!!!!!

  6. Milan Petrovic
    Member
    Posted 2 years ago #

    Thanks for reporting this. Fix in the next release.

Topic Closed

This topic has been closed to new replies.

About this Topic