
How to get admin user ID
Share This Post How to get admin User ID? It’s been really difficult for many to get back the admin user ID but it’s so
MyCred assigns different points to the users but it’s been sometime noticed that the users want to transfer points to another user and MyCred has a transfer form as default but to send a custom message with the transfer like a reason for transferring points which is not available with default form. Below snippets will help you to add custom message.
Also, see this if you don’t know how to allow the transfer of points with myCred.
Note: MyCred Plugin must be configured in order to use these snippets.
Let’s check how it is working…
This snippet will display a new field to the forum.
/**
* Display new fields to the form
*/
function ldninjas_add_message_field_in_transfer_form() {
?>
The snippet will save the custom message field value into the myCred database.
/**
* Save field value
*/
function ldninjas_save_message_field_values_data( $data, $transaction_id, $post ) {
$reason_to_transfer = isset( $post['message']['transfer_reason'] ) ? sanitize_textarea_field( $post['message']['transfer_reason'] ) : '';
$data['reason_to_transfer'] = $reason_to_transfer;
return $data;
}
add_filter( 'mycred_transfer_data', 'ldninjas_save_message_field_values_data', 10, 3 );
The snippet will add a new column in MyCred log where custom message will be displayed.
/**
* Adds new column in myCred log
*/
function ldninjas_add_extra_column_in_log( $columns, $class, $is_admin ) {
$columns['transfer-message'] = 'Reason to transfer';
return $columns;
}
add_filter( 'mycred_log_column_headers', 'ldninjas_add_extra_column_in_log', 10, 3 );
The snippet will display custom message on myCred log.
/**
* Display message on myCred log
*/
function ldninjas_display_message_content_log_column( $content, $log_entry ) {
if( empty( $log_entry->data ) ) {
return '';
}
$type = $log_entry->ref;
if( $type != 'transfer' ) {
return '';
}
$data = maybe_unserialize( $log_entry->data );
return $data['reason_to_transfer'];
}
add_filter( 'mycred_log_transfer-message', 'ldninjas_display_message_content_log_column', 10, 2 );
So, All you need to add this code snippet to your theme functions.php file to display custom message with myCred transfer. Enjoy!
Share This Post How to get admin User ID? It’s been really difficult for many to get back the admin user ID but it’s so
Share This Post Award GamiPress on RCPro Membership Renewal Do you think users can also be awarded points/badges/ranks while RCPro Membership renewal? Yes, you can
Share This Post Custom Message with myCRED Transfer MyCred assigns different points to the users but it’s been sometime noticed that the users want to
Once you send the details, we will be shortly back to you. Thanks!
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.