This function returns a given users current rank post object ID of a specific point type. If you are looking to get the users rank object, consider using mycred_get_users_rank instead.

This function is only available if the Ranks add-on is enabled.

Available since version 1.6


(string | int) Returns either the rank post object ID or an empty string if no rank is found.


Param Type Required Description
function mycred_get_users_rank_id(
$user_id int Yes

The users numeric ID.

$point_type string No

The point type key to return a rank for. Should only be used when you have ranks setup for more than one point type.

) { ... }


Example 1: Get the current users rank and display the ranks title.

$user_id = get_current_user_id();
$rank_id = mycred_get_users_rank_id( $user_id );

if ( $rank_id != '' )
	printf( 'Your current rank is: %s', get_the_title( $rank_id ) );
	echo 'You do not have a rank yet';