Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Adjust Transfers
- */
- add_filter( 'mycred_add', 'mycred_pro_custom_transfer_message', 99, 3 );
- function mycred_pro_custom_transfer_message( $reply, $request, $mycred ) {
- // If declined or not a transfer, bail
- if ( $reply === false || $request['ref'] != 'transfer' ) return $reply;
- // We want to insert the message to the recipient
- // Recipients can be identified by a positive value
- // as the sender will have a negative one.
- // This is not needed if you want to show the message to
- // both the sender and the recipient!
- if ( $request['amount'] > 0 ) {
- // Sanitize the message (also removed all html elements)
- $message = sanitize_text_field( $_POST['message_to_recipient'] );
- // Add points now
- $mycred->update_balance( $request['user_id'], $request['amount'] );
- // Add custom log entry
- // In this example we will append the message to the end
- // of the log entry but you could also just use a custom
- // template tag that you replace with the message i.e. %message%
- $mycred->add_to_log(
- $request['ref'],
- $request['user_id'],
- $request['amount'],
- $request['entry'] . $message,
- $request['ref_id'],
- $request['data'],
- $request['type']
- );
- // Since we just added points we need to return
- // "done" to prevent duplicates!!!
- return 'done';
- }
- // Always return a reply or you brake things
- return $reply;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement