opencredit / BadgeOS-Community-Add-on

The "BadgeOS Community Add-on" integrates BadgeOS features into BuddyPress and bbPress. Site members complete achievements and earn badges based on a range of community activity and triggers. This add-on to BadgeOS also includes the ability to display badges and achievements on user profiles and activity feeds.
GNU Affero General Public License v3.0
11 stars 8 forks source link

Renaming "achievements" in the BP menu to something else #54

Closed AntJanus closed 8 years ago

AntJanus commented 8 years ago

On the user's member page, achievements is added as another tab and is available via /members/$memberName/achievements, is there a hook or a setting I can change so that the achievements says badges instead? It'd be more congruent to the community I'm working with.

tw2113 commented 8 years ago

Doesn't look like we have anything set up for that type of customization. Best I can offer would be to copy/paste what we've done to set up the BP component, make the changes you need, and make sure to prevent ours from loading. Should all be possible without editing the Community Addon code itself.

AntJanus commented 8 years ago

@tw2113 yeah, that'd be awesome. If anything I'll just do a CSS/JS hack for the way it shows up in the profile and leave the URL be.

I see that it's set here: https://github.com/opencredit/BadgeOS-Community-Add-on/blob/master/includes/bp-members.php#L132 and that class is loaded here: https://github.com/opencredit/BadgeOS-Community-Add-on/blob/master/includes/bp-members.php#L73

I can't think of a way to override that unless there is some way to retrieve that object and set the options on it dynamically but I'm guessing that by that point, BP already uses that array of options and can't change them at runtime.

tw2113 commented 8 years ago

Completely untested, but perhaps remove this hook callback, add_action( 'bp_init', 'badgeos_community_loader', 1 ); and then add your own that calls your own class copy.

As an alternative to my idea above, this should get you the slugs changed:

function custom_change_badgeos_tab_slug( $slug ) {
    return 'custom-slug';
}
add_filter( 'bp_badgeos_slug', 'custom_change_badgeos_tab_slug' );
add_filter( 'bp_badgeos_root_slug', 'custom_change_badgeos_tab_slug' );

I documented majority of the hooks and filters in BuddyPress, so I knew there was likely something available. The two above are some dynamic ones found in /buddypress/bp-core/bp-core-component.php in the parent setup_globals() method. If you're fine with the css/js method for the link text, this should get you the rest of the way with the URL.

AntJanus commented 8 years ago

Ahh, awesome, thanks! I don't think I want to mess with the plugin code and saw that to do remove_action, I'd need the original function so I might do that and rehook it with my own extended class.

tw2113 commented 8 years ago

If you're going the remove_action route, I'd do a copy/paste of the entire class definition we have for the component, change your necessary parts, and hook up your own callback on that same action with the same internals as badgeos_community_loader but instead instantiate your class. May need to tinker with priority, in case your version is getting run before Community Addon is parsed.

Happy coding. Gonna close this ticket and create a new one regarding more potential filters.