Skip to content

Instantly share code, notes, and snippets.

@danielpowney
Created November 8, 2016 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpowney/7493d4109c05d6c6883a2592af6bc67d to your computer and use it in GitHub Desktop.
Save danielpowney/7493d4109c05d6c6883a2592af6bc67d to your computer and use it in GitHub Desktop.
<?php
// get post id - assumes in WP loop
global $post;
$post_id = $post->ID;
// get default rating form for post, this checks the filter settings, post meta and general settings
$rating_form_id = MRP_Utils::get_rating_form( $post_id );
// get current logged in user
$user_id = 0; // anonymous
$user = wp_get_current_user();
if ( $user && $user->ID ) {
$user_id = $user->ID;
}
// show rating form is not logged in or user has not yet rated, otherwise show rating item
// results in option block layout
if ( $user_id == 0 || ! MRP_Multi_Rating_API::user_rating_exists( $rating_form_id, $post_id, $user_id ) ) {
mrp_rating_form();
} else {
mrp_rating_item_results( array( 'layout' => 'options_block' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment