Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter screampuff

    (@screampuff)

    I was able to hide the tab with this code in bp-custom.php:

    function hide_achievements_from_users() {
    $role = xprofile_get_field_data( 'Membership' );
    if( $role !='Administrator' )
    bp_core_remove_nav_item('achievements');
    }
    add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );

    But you can still manually goto /username/achievements/ any idea how to block it completely?

    Thread Starter screampuff

    (@screampuff)

    Sorry that code above should read:

    function hide_achievements_from_users() {
    global $bp;
    if ((bp_loggedin_user_id() == bp_displayed_user_id()) || (current_user_can('administrator'))){
    return;
    }
    bp_core_remove_nav_item('achievements');
    }
    add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );
    Thread Starter screampuff

    (@screampuff)

    So it was a long process but I solved it. It required modding the files (first copying them to my theme)

    The files are:

    /wp-content/plugins/achievements/templates/achievements/loop-single-progress.php : add the following at the end of the opening php statement:

    if ( !current_user_can('manage_options') )
            return;

    This will hide the list of “Unlocked By” when you click on an achievement, unless you are an admin.

    /wp-content/plugins/achievements/templates/achievements/loop-progresses.php : add the same thing as above under do_action( 'dpa_template_before_progress_loop_block' );

    This will hide the actual h1 heading “Unlocked By” above the list in the previous file.

    /wp-content/plugins/achievements/templates/achievements/content-author-achievements : add the following at the end of the opening php statement

    if ( bp_loggedin_user_id() != bp_displayed_user_id() )
            wp_redirect( home_url( '404' ) );

    This will redirect a user to your theme’s 404 page (if you have one) if they try to manually type out a url by putting /achievements/ at the end of someone else’s profile.

    Finally add the following to /wp-content/plugins/bp-custom.php:

    function hide_achievements_from_users() {
    if ( bp_is_my_profile() || current_user_can('manage_options') ) {
    return;
    }
    bp_core_remove_nav_item('achievements');
    }
    add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );

    This will hide the achievements tab from users’ buddypress profiles unless they are viewing their own profile, or are an admin.

    Great, thanks for sharing Screampuff!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide achievements from other users?’ is closed to new replies.