myCRED_Rank
Description
The rank object contains the rank post object, the set title, logo details, requirements and user count.
Available since version 1.7
Interacting with Object
The rank object can be accessed via the mycred_get_rank function.
Object properties
Property | Type | Description | |
---|---|---|---|
myCRED_Rank Object (
|
|||
public $post_id |
int | The rank post objects ID. | |
public $post |
obj | The WordPress post object. | |
public $title |
string | The rank title. | |
public $minimum |
int or float | The minimum point requirement set for this rank. | |
public $maximum |
int or float | The maximum point requirement set for this rank. | |
public $count |
int | The total number of users with this rank. | |
public $has_logo |
bool | True if the rank has a logo attachment set or false if not. | |
public $logo_id |
int | The numeric attachment ID set as the rank logo. | |
public $logo_url |
string | The rank logo URL. This is the URL to the original file and not to cropped versions. | |
public $image_width |
int | The set value for the MYCRED_RANK_WIDTH constant. | |
public $image_height |
int | The set value for the MYCRED_RANK_HEIGHT constant. | |
public $point_type |
obj | Holds the myCRED_Point_Type object with information about the point type associated with this balance. | |
public $is_manual |
bool | Indicates if the rank is using manual mode. | |
)
|
Object Methods
public function __construct( $rank_id = NULL ) {
|
||||
Description: | Constructs and populates the object based on the given rank post ID. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$rank_id |
int | Yes | The rank post object ID. | |
} |
public function user_has_rank( $user_id = false ) {
|
||||
Description: | Returns TRUE if the given user has this rank else FALSE . |
|||
---|---|---|---|---|
Variable | Type | Required | Description | |
$user_id |
int | Yes | The users numeric ID. | |
} |
public function assign( $user_id = false ) {
|
||||
Description: | Assigns a specific user to this rank. Will return TRUE if successful else FALSE . |
|||
---|---|---|---|---|
Variable | Type | Required | Description | |
$user_id |
int | Yes | The users numeric ID. | |
} |
public function assign_all() {
|
||||
Description: | Will attempt to assign all users that meet the requirements set for this rank. | |||
---|---|---|---|---|
} |
public function divest( $user_id = false ) {
|
||||
Description: | Removes a given user from this rank. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$user_id |
int | Yes | The users numeric ID. | |
} |
public function divest_all() {
|
||||
Description: | Removes all users from this rank. Note that if the rank is set to use manual mode, this method will do nothing. | |||
---|---|---|---|---|
} |
public function delete( $delete_post = true ) {
|
||||
Description: | Deletes the rank post object. This method uses the divest_all() method before deleting the object. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$delete_post |
bool | No | Option to just divest all users or also delete the post object. | |
} |
public function get_image( $image = 'logo' ) {
|
||||
Description: | Constructs and populates the object based on the given rank post ID. | |||
---|---|---|---|---|
Variable | Type | Required | Description | |
$image |
string | Yes | Currently only supports the logo keyword. |
|
} |
Object Example
myCRED_Rank Object ( [post_id] => 2140 [post] => WP_Post Object ( [ID] => 2140 [post_author] => 1 [post_date] => 2013-11-22 12:24:20 [post_date_gmt] => 2013-11-22 11:24:20 [post_content] => [post_title] => Senior Member [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => senior-member [to_ping] => [pinged] => [post_modified] => 2014-05-22 00:39:05 [post_modified_gmt] => 2014-05-21 22:39:05 [post_content_filtered] => [post_parent] => 0 [guid] => http://website.com/?post_type=mycred_rank&p=2140 [menu_order] => 0 [post_type] => mycred_rank [post_mime_type] => [comment_count] => 0 [filter] => raw ) [title] => Senior Member [minimum] => 1000 [maximum] => 4999 [count] => 1 [has_logo] => 1 [logo_id] => 6627 [logo_url] => http://website.com/wp-content/uploads/2013/11/rank-three.png [image_width] => 250 [image_height] => 250 [point_type] => myCRED_Point_Type Object ( [cred_id] => mycred_default [singular] => Token [plural] => Tokens [prefix] => [suffix] => tk. [format] => Array ( [type] => bigint [decimals] => 0 [separators] => Array ( [decimal] => . [thousand] => , ) ) ) )