USharing
开放博客

Mycred 如何显示 “游客推广” 成功个数及指定确认评论执行

* mycred 如何显示 “游客推广” 成功个数:
1, short code 实现方法:
[mycred_total_points ref=”visitor_referral”]
类似:[mycred_total_points ref=”signup_referral”]
查看历史记录:[mycred_history ref=”visitor_referral,signup_referral”]

2, 函数实现方法:

Example 1: Get all references with their count no matter which point type they belong to.

$references = mycred_count_all_ref_instances( -1, 'DESC', 'all' );
if ( ! empty( $references ) ) {
  foreach ( $references as $reference => $count ) {

    echo $reference . ' ' . $count;

  }
}

Example 2: Get the top 10 references for the default point type.

$count = mycred_count_all_ref_instances( 10 )
if ( ! empty( $references ) ) {
  foreach ( $references as $reference => $count ) {

    echo $reference . ' ' . $count;

  }
}

Example 3: Count the number of times a user has received points for approved comments.

$user_id = 1;
$count   = mycred_count_ref_instances( 'approved_comment', $user_id );

Example 4: Count the number of times points have been spent on paying for a WooCommerce order.

$payments = mycred_count_ref_instances( 'woocommerce_payment' );

 

来源:https://codex.mycred.me/functions/mycred_count_all_ref_instances/

 

* 指定post id 留言确认方法:

Example 1: Check if a user has a log entry for receiving points for a particular comment.

$user_id    = 1;
$comment_id = 10;

if ( mycred_count_ref_id_instances( 'approved_comment', $comment_id, $user_id ) > 0 ) {

  // User has received points for this comment

}

**Reference 参考,如ref=”visitor_referral”
https://codex.mycred.me/chapter-vi/log-references/

Core Hooks
Reference Description
registration Website Registration
site_visit Website Visit
view_content Viewing Content
view_content_author Getting a view on your content
logging_in Logging in
publishing_content Publishing Content
approved_comment Approved Comment
unapproved_comment Unapproved Comment
spam_comment SPAM Comment
deleted_comment Deleted Comment
link_click Link Click
watching_video Watching Video
visitor_referral Visitor Referral
signup_referral Signup Referral
赞(0) 打赏
未经允许不得转载:USharing » Mycred 如何显示 “游客推广” 成功个数及指定确认评论执行

觉得文章有用就打赏一下文章作者

微信扫一扫打赏