daily pastebin goal
78%
SHARE
TWEET

WooCommerce - List current user's reviews

lorro Feb 27th, 2017 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   // WooCommerce - List current user's reviews
  3.   // code goes in functions.php for child theme
  4.   // Usage: [show_my_reviews]
  5.   // No parameters
  6.   // not tested
  7.   add_shortcode( 'my_reviews', 'show_my_reviews' );
  8.   function show_my_reviews() {
  9.     $current_user = wp_get_current_user();
  10.     $args = array (
  11.       'post_type' => 'product',
  12.       'user_id' => $current_user->ID
  13.     );
  14.     $comments = get_comments( $args );
  15.     wp_list_comments( array( 'callback' => 'woocommerce_comments' ), $comments);
  16.   }
RAW Paste Data
Top