Created
November 8, 2016 22:31
-
-
Save danielpowney/7493d4109c05d6c6883a2592af6bc67d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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