• Resolved himbo

    (@himbo)


    I’d like to process some data from the plugin in some custom php code. All I have is a user_login name and I would need the data for all the reviews related to that name. Sadly I did not find any hook or shortcode that seemed capable of doing that. At least from my limited perspective. Is it somehow possible in an easy way or do I need some complicated sql query?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Use the get_user_by function to get the User ID from the login name and then use the glsr_get_reviews function to get the review data.

    For example:

    $user = get_user_by('login', $user_login);

    if ($user) {
    $reviews = apply_filters('glsr_get_reviews', [], [
    'user__in' => $user->ID,
    ]);
    }

    Read the documentation for the glsr_get_reviews function on the Site Reviews > Help & Support > Functions page.

    Thread Starter himbo

    (@himbo)

    I thought it would work. But the problem is, that the $reviews variable still only holds some html. Though I would need it’s data fields separately like the commentators name, the text or the rating. It wouldn’t be too difficult to extract that information, but it seems to be an ugly hack.

    • This reply was modified 4 months, 2 weeks ago by himbo.
    Thread Starter himbo

    (@himbo)

    My error. It seems php’s dynamic type system made me completely mad. $reviews is a php object that keeps all the information needed, even if I still don’t fully understand why it outputs html when echoed.

    Thank you for your help. I really appreciate it.

    Plugin Author Gemini Labs

    (@geminilabs)

    It’s an arrayable object that echos to rendered HTML as shown in the documentation.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.