This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Unpublish users Posts | |
* If a user reaches or exceeds the minimum balance | |
* we unpublish all their posts. | |
* @version 1.0 | |
*/ | |
add_filter( 'mycred_add', 'mycred_unpublish_posts_on_minus', 999, 3 ); | |
function mycred_unpublish_posts_on_minus( $reply, $request, $mycred ) { | |
if ( $reply === false ) return; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Users Rank Progress | |
* This shortcode will render the users current rank progress using the Visual Composer Progress Bar shortcode. | |
* Shows either the current users rank progress or a given user ids. Returns the content if user is not logged in. | |
* Requries myCRED 1.4 | |
* @version 1.1 | |
*/ | |
add_shortcode( 'mycred_rank_progress', 'mycred_pro_users_rank_progress' ); | |
function mycred_pro_users_rank_progress( $atts, $content = NULL ) { | |
// Make sure we are logged in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Step 1 - Add new ticket preference | |
* In this example we will insert this under "Participation" section | |
* of the lottery edit screen. | |
* @version 1.0 | |
*/ | |
add_action( 'mycred_edit_lotto_participation', 'add_max_lottery_entries_settings' ); | |
function add_max_lottery_entries_settings( $lottery ) { | |
$tickets = get_post_meta( $lottery->id, '_tickets', true ); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show 5 Users of a specific rank | |
* This code snippet is placed inside the Loop of the archive-mycred_rank.php file | |
* Requires BuddyPress + myCRED 1.3+ | |
* @version 1.0 | |
*/ | |
if ( function_exists( 'mycred_get_users_of_rank' ) && function_exists( 'bp_core_get_user_domain' ) ) { | |
$five_users = mycred_get_users_of_rank( get_the_ID(), 5 ); | |
if ( ! empty( $five_users ) ) { | |
echo '<p><strong>my</strong>CRED members with this rank:</p><div class="mycred-users-of-rank">'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Step 1 - Create custom Shortcode | |
* Creates a custom buyCRED shortcode that includes | |
* the marker attribute that is passed on to the gateway. | |
* @version 1.0 | |
*/ | |
add_shortcode( 'mycred_custom_buy', 'mycred_render_custom_buy_shortcode' ); | |
function mycred_render_custom_buy_shortcode( $atts, $title = 'Buy Points' ) { | |
if ( ! function_exists( 'mycred' ) ) return 'myCRED is not installed'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode( 'mycred_manual_adjustments', 'mycred_render_manual_adjustments' ); | |
function mycred_render_manual_adjustments( $atts, $content = NULL ) { | |
// Must be logged in | |
if ( ! is_user_logged_in() ) return; | |
// myCRED must be enabled | |
if ( ! function_exists( 'mycred' ) ) return 'myCRED is not installed'; | |
// Load myCRED | |
$mycred = mycred(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'mycred_add', 'enforce_mycred_form_limit', 10, 3 ); | |
function enforce_mycred_form_limit( $reply, $request, $mycred ) { | |
// First we only want to target form submissions | |
if ( $request['ref'] != 'contact_form_submission' ) ) | |
return $reply; | |
// If already declined by someone, horour it | |
if ( $reply !== true ) return $reply; | |
// Limit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'mycred_paid_for_woo', 'mycred_apply_purchased_disk_space', 10, 2 ); | |
function mycred_apply_purchased_disk_space( $order, $cui ) { | |
if ( ! function_exists( 'get_site_option' ) ) return; | |
$space_bought = 0; | |
// Loop though all items in order to see if we bought space | |
$items = $order->get_items(); | |
foreach ( $items as $item ) { | |
// Check for the custom field we set with the amount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Restrict bbPress Forum Points | |
* If a forum has the custom field "NO_MYCRED_POINTS" set to "yes" | |
* no points are awarded for any action taken in the forum. | |
* @version 1.0 | |
*/ | |
add_filter( 'mycred_add', 'mycred_disable_bbp_forum_points', 98, 3 ); | |
function mycred_disable_bbp_forum_points( $reply, $request, $mycred ) { | |
// If already declined or bbPress is not installed, bail. | |
if ( $reply === false || ! function_exists( 'bbp_get_topic_forum_id' ) ) |