Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add Give Rewards button under bbPress avatar
- add_action( 'bbp_theme_after_reply_author_details', 'mycred_pro_add_reward_button_in_bbp' );
- function mycred_pro_add_reward_button_in_bbp() {
- // Make sure myCRED is around
- if ( ! function_exists( 'mycred_exclude_user' ) ) return;
- $reply_id = bbp_get_reply_id();
- if ( bbp_is_reply_anonymous( $reply_id ) ) return;
- $user_id = bbp_get_reply_author_id( $reply_id );
- if ( mycred_exclude_user( $user_id ) ) return;
- echo do_shortcode( '[mycred_send amount="10" to="' . $user_id . '" ref="rewards_given" log="Rewards Given"]Give Rewards[/mycred_send]' );
- }
- // Stop point deduction when a member gives points to other
- add_filter( 'mycred_add', 'mycred_pro_give_rewards_without_loss', 999, 3 );
- function mycred_pro_give_rewards_without_loss( $reply, $request, $mycred ) {
- extract( $request );
- // Give the recipient points but decline the transaction so the user sending the points is not charged
- if ( $reply === true && $ref == 'rewards_given' && $type === MYCRED_DEFAULT_TYPE_KEY ) {
- $amount = abs( $amount );
- $mycred->add_to_log(
- $request['ref'],
- $request['ref_id'],
- $amount,
- $request['entry'],
- $request['user_id'],
- $request['data'],
- $request['type']
- );
- $mycred->update_users_balance( (int) $request['ref_id'], $amount, $request['type'] );
- return false;
- }
- return $reply;
- }
- // Adjust the language
- add_filter( 'mycred_send_language', 'mycred_pro_adjust_send_language' );
- function mycred_pro_adjust_send_language( $js ) {
- $js['error'] = 'Sent';
- return $js;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement