Change Rank Name

front page Forums Community Change Rank Name

This topic contains 9 replies, has 2 voices, and was last updated by Avatar Gabriel Galvão 6 years, 1 month ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #4272
    Avatar
    Gabriel Galvão

    Hi there,

    I want to change the Name of the “Rank”.

    In my case i want to change the name to “Reputation” because i already have a rank system on my website. The Rank system are from achievements and the “Rank” from MYcred are for reputation.

    There is a easy way to do that?

    Thanks in advance!

    #4273
    Avatar
    WPExperts

    Hi.

    You can use the mycred_register_ranks filter which is used when the “Rank” post type is registered with WordPress. You could change the labels used for Ranks to anything you want.

    Example:

    add_filter( 'mycred_register_ranks', 'mycred_pro_adjust_rank_post_type' );
    function mycred_pro_adjust_rank_post_type( $args ) {
    	$args['labels']['name'] = 'Reputation';
    	$args['labels']['singular_name'] = 'Rep';
    	
    	return $args;
    }
    

    For more information on what arguments are available, you can consult the WordPress Codex for the register_post_type function.

    #4277
    Avatar
    Gabriel Galvão

    Thanks for the reply Gabriel.
    Your work is excellent, and must be awarded! No kidding..

    Just a newbie question, where i put this code?

    And Merry Christmas for you and your Family!

    #4284
    Avatar
    WPExperts

    Hey.

    The above code would go in your themes functions.php file or in your custom plugin (if you are creating one).

    You can pretty much change anything about the “Rank” post type via this filter except for the post type id, which is set to “mycred_rank”.

    And a Merry Christmas to you too.

    #4336
    Avatar
    Gabriel Galvão

    Hi Gabriel,

    I put the code on functions.php but nothing change.

    I’am using this plugin WPAchievments from codecan.. and they have support for your plugin. But WPA plugin have a rank too, and of course is named Rank.

    So i have 2 ranks, and i want to use them. I really just need to change the name of the rank from MYcred or WPA.

    Thanks.

    #4353
    Avatar
    WPExperts

    Hey.

    The above code will change the post type title (depending on which arguments you changed). If you are on the other hand looking to change i.e. the User List column label (which is “Rank”), you would need to change it by hooking into manage_users_columns after myCRED does.

    add_filter( 'manage_users_columns', 'mycred_pro_adjust_rank_column', 99 );
    function mycred_pro_adjust_rank_column( $columns ) {
    	unset( $columns['mycred-rank'] );
    	$columns['mycred-rank'] = 'Rep';
    	return $columns;
    }
    
    #4359
    Avatar
    Gabriel Galvão

    Hi

    I used this code and doesn’t change too, this may change the user list rank right?

    What i want to change is this:
    http://img38.imageshack.us/img38/6148/s7bu.png

    Thanks Gabriel for the reply and sorry take too much of your time.

    #4389
    Avatar
    WPExperts

    Ah! Now I understand.

    In the current version of myCRED the only way to do this is to disable showing ranks in users profiles and then insert it yourself with the proper label.

    On your myCRED > Settings page under “Ranks”, select “Do not show” for “Rank in BuddyPress” and then add it in yourself:

    add_action( 'bp_before_member_header_meta',  'insert_rank_in_profile_header_custom' );
    function insert_rank_in_profile_header_custom() {
    	// Only show to admins and the user
    	if ( bp_is_my_profile() || mycred_is_admin() ) {
    		$user_id = bp_displayed_user_id();
    		// Check for exclusions
    		if ( $this->core->exclude_user( $user_id ) ) return;
    
    		// Get the users rank (returns the name by default)
    		$rank_name = mycred_get_users_rank( $user_id );
    		echo '<div id="mycred-my-rank">Rep: ' . $rank_name . '</div>';
    	}
    }
    
    #4462
    Avatar
    Gabriel Galvão

    Hi Gabriel,

    i use this code on functions.php and in return i get this:

    Fatal error: Using $this when not in object context in /wp-content/themes/myowntheme/functions.php on line 556

    Thanks.

    #4513
    Avatar
    Gabriel Galvão

    i have to exclude this line
    if ( $this->core->exclude_user( $user_id ) ) return;

    to make work, i don’t know what changes but looks great til now.

    Anyway thanks for the help.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

11