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
function mycred_pro_detect_point_purchases( $ran, $request, $mycred ) { | |
extract( $request ); | |
// New point purchase | |
if ( substr( $ref, 14 ) == 'buy_creds_with' ) { | |
$transaction = explode( '|', $data['sales_data'] ); | |
$transaction_id = $data['txn_id']; |
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
/** | |
* Disable Notifications | |
* @since 1.0 | |
* @version 1.0.1 | |
*/ | |
function mycred_pro_disable_notices( $modules ) { | |
$blog_to_block = 4; | |
if ( get_current_blog_id() == $blog_to_block && array_key_exists( 'notices', $modules['solo'] ) ) { |
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
// Hide cost messages for everyone | |
add_filter( 'mycred_bp_show_charge_message_cost', '__return_false' ); | |
add_filter( 'mycred_bp_show_charge_reply_cost', '__return_false' ); | |
// Hide cost messages for users with a certain capability | |
function mycred_pro_maybe_hide_bp_charge_cost( $show = true ) { | |
if ( current_user_can( 'bp_charges_pay' ) ) | |
return false; |
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
if ( function_exists( 'mycred_get_woo_product_reward' ) ) { | |
$product_id = 1; | |
$point_type = MYCRED_DEFAULT_TYPE_KEY; | |
$reward = mycred_get_woo_product_reward( $product_id, NULL, $point_type ); | |
if ( $reward !== false && $reward != '' ) | |
printf( 'Earn %s Points buying this product.', $reward ); | |
} |
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
function mycred_pro_timeframe_total_balance( $query, $atts ) { | |
if ( ! empty( $atts ) && array_key_exists( 'based_on', $atts ) && $atts['based_on'] == 'balance' ) { | |
if ( array_key_exists( 'total', $atts ) && $atts['total'] == 1 && array_key_exists( 'timeframe', $atts ) && $atts['timeframe'] != '' ) | |
$query = str_replace( "l.ref = 'manual' ) )", "l.ref = 'manual' ) ) AND time >= " . strtotime( $atts['timeframe'], current_time( 'timestamp' ) ), $query ); | |
} | |
return $query; |
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
function mycred_pro_maybe_hide_message_charge( $content ) { | |
// Only applicable to texts starting with New Reply: | |
if ( substr( $content, 0, 10 ) == 'New Reply:' && function_exists( 'bp_loggedin_user_id' ) ) { | |
$user_id = bp_loggedin_user_id(); | |
// If a user does not the bp_charges_pay capability | |
// hide the message | |
if ( ! user_can( 'bp_charges_pay', $user_id ) ) |
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
/** | |
* Pretend User Can Afford | |
* Pretend users that are exempt from being charged can afford to send | |
* new messages even if their balance is zero. | |
* @version 1.0 | |
*/ | |
function mycred_pro_pretend_user_can_afford( $can_afford ) { | |
$user_id = bp_loggedin_user_id(); |
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
/** | |
* Maybe Charge Message | |
* Exempt users with a specific capability from being | |
* charged for sending private messages in BP Charges. | |
* @version 1.0 | |
*/ | |
function mycred_pro_maybe_charge_new_message( $charge, $thread_id, $module ) { | |
$user_id = bp_loggedin_user_id(); |
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
/** | |
* Reward Store Sales | |
* @version 1.0 | |
*/ | |
function mycred_pro_reward_store_sales( $order_id ) { | |
// Prevent crashes if myCRED gets disabled | |
if ( ! function_exists( 'mycred' ) ) return; | |
// Get order |
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
/** | |
* Customize UserPro Message | |
* @version 1.0 | |
*/ | |
function mycred_pro_custom_userpro_message( $message ) { | |
return '<div class="userpro-msg-notice">Insufficient funds. Please <a href="http://yourwebsite.com/buy-points/">top-up</a> your account to send further messages.</div>'; | |
} | |
add_filter( 'mycred_userpro_insufficient', 'mycred_pro_custom_userpro_message' ); |