Skip to content

Instantly share code, notes, and snippets.

@gabrielmerovingi
Created March 18, 2014 09:22
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/9616503 to your computer and use it in GitHub Desktop.
Save gabrielmerovingi/9616503 to your computer and use it in GitHub Desktop.
A very basic example of using the mycred_send shortcode to allow an administrator of a bbPress forum to send points to the topic author. In this example, we send points as a thank you for helping in the support forum or points for reporting bugs.
/**
* bbPress Give Points
* Allows admins to give points to topic authors.
* @version 1.0
*/
add_action( 'bbp_theme_after_reply_content', 'mycred_pro_insert_forum_buttons' );
function mycred_pro_insert_forum_buttons() {
// Get Reply Author ID
$reply_author_id = bbp_get_reply_author_id( bbp_get_reply_id() );
// Only visible to admins when viewing someone elses reply
if ( current_user_can( 'edit_users' ) && get_current_user_id() != $reply_author_id ) {
// Create all the available mycred_send buttons.
// Using mycred_send means that the current user will give points from their
// own account.
$award_options = array();
$award_options[] = '[mycred_send amount="10" to="' . $reply_author_id . '" log="%plural% for helping in the support forum" ref="support_forum"]Support[/mycred_send]';
$award_options[] = '[mycred_send amount="15" to="' . $reply_author_id . '" log="%plural% for confirmed bug" ref="bug_reporting"]Confirmed Bug[/mycred_send]';
echo do_shortcode( '<div class="mycred-edit-user"><strong>Awards</strong><br />' . implode( ' ', $award_options ) . '</div>' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment