Codex / mycred/balance / Filters / mycred_run_this


This filter allows you to make adjustments to a transaction request before it is executed. If you need to stop a transaction you can set the amount to zero, however you should use the mycred_add filter to determine if a transaction should be stopped.

Available since version 1.1


Param Type Required Description
$request array No

An associative array representing the transaction that is to be processed.

$mycred obj No

The myCRED_Settings class object processing the transaction request.

Used By

Package Prio. Description
Not used by any built-in package.


Example 1: Multiply the amount of points users gets based on their WordPress role. Administrators are excluded.

add_filter( 'mycred_run_this', 'mycred_pro_balance_adjustment_multiply', 10, 2 );
function mycred_pro_balance_adjustment_multiply( $request, $mycred ) {

	// Get the user ID
	$user_id = absint( $request['user_id'] );

	// Ignore admins
	if ( user_can( $user_id, 'promote_users' ) ) return $request;

	// If user is an editor, quadruple the amount
	if ( user_can( $user_id, 'moderate_comments' ) )
		$request['amount'] = $request['amount'] * 4;

	// If user is a author, triple the amount
	elseif ( user_can( $user_id, 'publish_posts' ) )
		$request['amount'] = $request['amount'] * 3;

	// If user is a contributor, double the amount
	elseif ( user_can( $user_id, 'edit_posts' ) )
		$request['amount'] = $request['amount'] * 2;

	return $request;


Last edited September 1, 2016