• Resolved kayapati

    (@kayapati)


    HI

    I am working ultimate member plugin and I would like to display this review tab in User Profile page, I already added custom Tab naming “Reviews” and “Submit Reviews” added the shortcode as per doccumentaion, reviews are displaying, but the same reviews are displaying for all user profile pages, can any one tell me how to reviews to be appeared for each other based?

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

    (@geminilabs)

    You can do something like this (assuming that your Ultimate Members are the ones submitting the reviews):

    /**
     * Restrict reviews to those submitted by the current Ultimate Members user profile
     * Paste this in your active theme's functions.php file.
     * @param WP_Query $query
     * @return void
     */
    add_action( 'pre_get_posts', function( $query ) {
        if( $query->get( 'post_type' ) != 'site-review' )return;
        if( function_exists( 'um_profile_id' ) && $profileId = um_profile_id() ) {
            $query->set( 'author', $profileId );
        }
    });
    Thread Starter kayapati

    (@kayapati)

    I added the above code in function.php, but its not working.

    When I logged in as other user and gave review but the the review tab is empty.

    you can check here:

    https://kayapati.com/demos/alexia/user/ramkm/?profiletab=reviews

    • This reply was modified 5 years, 7 months ago by kayapati.
    Plugin Author Gemini Labs

    (@geminilabs)

    I am unfamiliar with the Ultimate Members plugin, so am unsure how it works with the user ID on the user profile page.

    Will look into this later.

    Plugin Author Gemini Labs

    (@geminilabs)

    Are your members themselves being reviewed, or do your members provide the reviews?

    Plugin Author Gemini Labs

    (@geminilabs)

    The code below works for me:

    /**
     * Adds the Reviews tab to the user profile page
     * @return array
     */
    add_filter( 'um_profile_tabs', function( $tabs ) {
        $tabs['reviews'] = [
            'name' => 'Reviews',
            'icon' => 'um-faicon-pencil',
            'default_privacy' => 0,
        ];
        return $tabs;
    }, 1000 );
    
    /**
     * Prints the shortcode to the Reviews tab on the user profile page
     * @return void
     */
    add_action( 'um_profile_content_reviews_default', function( $args ) {
        echo do_shortcode( '[site_reviews count=10 pagination=ajax]' );
    });
    
    /**
     * Restricts reviews shown on the Reviews tab to those submitted by the user
     * @return void
     */
    add_action( 'pre_get_posts', function( $query ) {
        if( $query->get( 'post_type' ) != 'site-review' )return;
        if( function_exists( 'um_profile_id' ) && $profileId = um_profile_id() ) {
            $query->set( 'author', $profileId );
        }
    });

    However, this will only work for displaying the reviews. It will not work for the summary. It is not currently possible to restrict the rating summary counts to reviews submitted by the user.

    Plugin Author Gemini Labs

    (@geminilabs)

    Topics with no reply in over a week are automatically marked as resolved.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Reviews form for author pages?’ is closed to new replies.