Skip to content

Instantly share code, notes, and snippets.

@gabrielmerovingi
Created November 30, 2015 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielmerovingi/952eb67758a6daf7363b to your computer and use it in GitHub Desktop.
Save gabrielmerovingi/952eb67758a6daf7363b to your computer and use it in GitHub Desktop.
/**
* Example 1: Transfer Messages
* Step 1 : Insert Message Field
* @version 1.0
*/
add_action( 'mycred_transfer_form_to', 'mycred_pro_transfer_message_field' );
function mycred_pro_transfer_message_field() {
echo '<label>Message</label><input type="text" name="transfer-message" id="mycred-transfer-message" value="" placeholder="Optional message to recipient" />';
}
/**
* Step 2 : Save Message
* @version 1.0
*/
add_filter( 'mycred_transfer_data', 'mycred_pro_save_transfer_message', 10, 3 );
function mycred_pro_save_transfer_message( $data, $transaction_id, $post ) {
// Default message.
$message = 'No message';
// If a message is set
if ( $post['transfer-message'] != '' )
$message = sanitize_text_field( $post['transfer-message'] );
// Add to the data array
$data['message'] = $message;
// return the results
return $data;
}
/**
* Step 3 : Show the message
* @version 1.0
*/
add_filter( 'mycred_parse_log_entry_transfer', 'mycred_pro_show_message_in_log', 10, 2 );
function mycred_pro_show_message_in_log( $content, $log_entry ) {
// Unserialize data
$data = maybe_unserialize( $log_entry->data );
// Default message
$message = 'No message';
if ( isset( $data['message'] ) )
$message = $data['message'];
// Replace and return
return str_replace( '%message%', $message, $content );
}
@ZeeshanAslam123
Copy link

how to display look like can you please upload that image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment