• Can you please demonstrate the best way (in terms of performance) to execute an IF current user is on x points, then… elseif… else. Also how to do the same with ranks if possible.

    Finally, which of these would be better to execute when considering server performance?

    http://wordpress.org/plugins/mycred/

Viewing 1 replies (of 1 total)
  • Plugin Author myCred

    (@designbymerovingi)

    Ranks are posts, so you can query posts in WordPress in several different way and it all comes down to what your intention is and what information about the post you need.
    For example if you just want the Rank Post ID, there is no need to query the entire post object etc.

    Points are stored as user meta so you can always get it using get_user_meta().

    // Balance
    $balance = get_user_meta( $user_id, 'mycred_default', true );

    A users rank is also stored as a meta so you can get a users rank the same way:

    // Rank
    $rank_id = get_user_meta( $user_id, 'mycred_rank', true );

    Using it in an IF statement:

    if ( $balance == 0 ) {
    	// zero points
    }
    elseif ( $balance > 0 && $balance < 100 ) {
    	// balance between 1 and 99
    }
    else {
    	// all else
    }
Viewing 1 replies (of 1 total)
  • The topic ‘IF statement using user's points or rank’ is closed to new replies.