• Resolved tavomenas

    (@tavomenas)


    With site review I can show the reviewr’s name or link to his gravar profile.
    As i have a membership area on my website, can I make the reviewer’s name would be a link to his account in my membership area?

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

    (@geminilabs)

    /**
     * Convert the author name to an author link (if the author is an existing user)
     * Paste this in your active theme's functions.php file.
     * @param \GeminiLabs\SiteReviews\Review|object $review
     * @param \WP_Post $post
     * @return \GeminiLabs\SiteReviews\Review|object
     */
    add_filter( 'site-reviews/get/review', function( $review, $post ) {
        if( $user = get_userdata( $review->user_id )) {
            $authorUrl = get_author_posts_url( $user->ID );
            $review->author = '<a href="'.$authorUrl.'">'.$review->author.'</a>';
        }
        return $review;
    }, 10, 2 );
    • This reply was modified 6 years, 1 month ago by Gemini Labs.
    Thread Starter tavomenas

    (@tavomenas)

    Thankyou very much! It’s working perfectly

    rayorlana

    (@rayorlana)

    Hi, I was wondering if it’s possible to wrap the review avatar also inside a link to reviewers profile as above?
    The structure will probably be like
    <div class="glsr-review-avatar"><a href=""></a><img src=""></a></div>

    • This reply was modified 6 years ago by rayorlana.
    Plugin Author Gemini Labs

    (@geminilabs)

    This will only work if you are using the latest unreleased (but stable) v3.0 beta of Site Reviews: https://pastebin.com/raw/Mgr28aJs

    /**
     * Convert the avatar to an author link (if the author is an existing user)
     * Paste this in your active theme's functions.php file.
     * @param string $avatar
     * @param \GeminiLabs\SiteReviews\Review $review
     * @return string
     */
    add_filter( 'site-reviews/review/wrap/avatar', function( $avatar, $review ) {
        if( $user = get_userdata( $review->user_id ) 
            && glsr_get_option( 'reviews.avatars' ) == 'yes' ) {
            $authorLink = '<a href="'.get_author_posts_url( $user->ID ).'">%s</a>';
            $avatar = sprintf( $authorLink, $avatar );
        }
        return $avatar;
    }, 10, 2 );
    Plugin Author Gemini Labs

    (@geminilabs)

    @rayorlana The code example above will throw a PHP warning in the PHP logs if the user does not exist. Please instead see: https://pastebin.com/mZftwuFm

    rayorlana

    (@rayorlana)

    I see. Thanks for the awesome support! Looking forward to the new released version later.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Link to reviewer’s profile’ is closed to new replies.