View myCRED: Weekly Leaderboard Example
/** | |
* Custom myCRED Widget: This weeks leaderboard | |
* This widget will show this weeks leaderbaord with the option to set | |
* a title, the number of users to include and if it should be visible for | |
* non-members. | |
* @install Paste into your theme or child-themes functions.php file or custom plguin. | |
* @author Gabriel S Merovingi | |
* @version 1.3 | |
*/ | |
add_action( 'mycred_widgets_init', 'mycred_load_this_weeks_leaderboard_widget' ); |
View mycred-woo-coupon
/** | |
* Convert myCRED Points into WooCommerce Coupon | |
* Requires myCRED 1.4 or higher! | |
* @version 1.3.1 | |
*/ | |
add_shortcode( 'mycred_to_woo_coupon', 'mycred_pro_render_points_to_coupon' ); | |
function mycred_pro_render_points_to_coupon( $atts, $content = NULL ) { | |
// Users must be logged in | |
if ( ! is_user_logged_in() ) |
View Apply Default OG:Image for Jetpack
/** | |
* Apply Default OG:Image for Jetpack | |
* When looking for images in posts that falls under "is_singular" | |
* and Jetpack does not find an image, we apply our own default image | |
* instead of the blank WordPress thumb. | |
* @version 1.0 | |
*/ | |
add_filter( 'jetpack_images_get_images', 'apply_default_image_for_jetpack_seo', 10, 3 ); | |
function apply_default_image_for_jetpack_seo( $media, $post_id, $args ) { | |
// Jetpack_PostImages::get_images did not find anything |
View myCRED to MarketPress Coupon
/** | |
* Convert myCRED Points into MarketPress Coupon | |
* @version 1.1 | |
*/ | |
add_shortcode( 'mycred_to_mpress_coupon', 'mycred_pro_render_points_to_marketpress_coupon' ); | |
function mycred_pro_render_points_to_marketpress_coupon( $atts, $content = NULL ) { | |
// Users must be logged in | |
if ( ! is_user_logged_in() ) | |
return 'You must be logged in to generate store coupons.'; |
View BP Checkin Hook for myCRED
/** | |
* BP Checkins | |
* @requires myCRED 1.3 + | |
* @since 0.1 | |
* @version 1.0 | |
*/ | |
if ( class_exists( 'myCRED_Hook' ) && ! class_exists( 'myCRED_BP_Checkins' ) ) { | |
class myCRED_BP_Checkins extends myCRED_Hook { | |
/** |
View WP Shortcode: myCRED Sell Content Limit
/** | |
* Custom Shortcode: Limited Content Purchases | |
* Example WordPress shortcode to impose a maximum number of times | |
* a user can purchase a post in WordPress using the myCRED Sell Content add-on. | |
* Requires myCRED 1.4 or higher! | |
* @version 1.1 | |
*/ | |
add_shortcode( 'mycred_sell_this_limited', 'mycred_render_sell_this_limited' ); | |
function mycred_render_sell_this_limited( $atts, $content = NULL ) { | |
// First make sure we do not get an error if myCRED gets deactivated |
View Max Content Purchases
/** | |
* Disable Content Sales | |
* Disabled content sales after 3 purchases. | |
* @version 1.0 | |
*/ | |
add_filter( 'mycred_add', 'mycred_limit_content_sales', 10, 3 ); | |
function mycred_limit_content_sales( $reply, $request, $mycred ) { | |
// Only apply this to content purchases | |
if ( $reply === false || $request['ref'] != 'buy_content' ) return $reply; |
View Custom WP Shortcode: Lottery Winners
/** | |
* [mycred_lottery_results] Shortcode Render | |
* @since 1.0 | |
* @version 1.2 | |
*/ | |
if ( ! function_exists( 'mycred_lotto_render_draws' ) ) : | |
function mycred_lotto_render_draws( $atts, $content = NULL ) | |
{ | |
extract( shortcode_atts( array( | |
'id' => NULL, |
View myCRED: Max. Comment Points
add_filter( 'mycred_add', 'mycred_absolute_limit_for_comments', 20, 3 ); | |
function mycred_absolute_limit_for_comments( $reply, $request, $mycred ) { | |
// Ignore declined instances or instances that are not comment related | |
if ( $reply === false || $request['ref'] != 'approved_comment' ) return $reply; | |
// The user ID | |
$user_id = absint( $request['user_id'] ); | |
// Count the number of times this user has received points for comments. | |
$total = mycred_count_ref_instances( 'approved_comment', $user_id ); |
OlderNewer