Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • @screampuff

    Participant

    Sorry, it is working, edited that post but was a moment late. The issue was I had just updated Buddypress and forgot to create a new language file from the updated .pot

    @screampuff

    Participant

    Thanks, got it working with the language file!

    @screampuff

    Participant

    Shane you had it all along, but it’s actually the file content-author-achievement.php that does do_action( 'dpa_template_before_achievements_loop_block' ); for a specific user.

    I put the check user check in that file and it’s working exactly how I wanted.

    Thanks so much for the help guys, I’ve spent too much time trying to do this!

    @screampuff

    Participant

    Also my site is private and can only be accessed when logged in, so I’m wondering if I can edit line line 47 in that same code to include the user check and simply display the “Invalid User ID specified.” If someone tries to view another user’s achievements list. That would be fine with me.

    I’m still new to WP/BP and PHP in general if you haven’t noticed 😉

    @screampuff

    Participant

    Sorry, I should have done it before posting.

    Yes the hook is you mentioned is in that template, I ran the user check and it was successful, however it also removed the main list of achievements.

    Also I was looking here: https://github.com/paulgibbs/achievements/blob/master/src/includes/class-dpa-wpcli-achievements-users-command.php#L33

    And it looks like this is where the list for a specified user is created, but I wasn’t able successfully run a user check on it, but I assume that’s because it’s not going through buddypress.

    @screampuff

    Participant

    Thanks for that suggestion Shane, users should still be able to see mysite.com/achievements which simply lists all available achievements. If I put a redirect on that will it prevent users from seeing this?

    @screampuff

    Participant

    No luck with

    if ( bp_is_user() && bp_is_current_component( 'achievements' ) && bp_is_current_action( 'all' ) )
        return;

    My guess is that since I removed the tab with bp_core_remove_nav_item('achievements'); that it is treating it like Buddypress is disabled like you mentioned above.

    @screampuff

    Participant

    Thanks for the reply Henry.

    I experimented with the code but couldn’t get it to work. I believe it has something to do with if ( bp_current_action() != 'achievements' )

    I’m not sure if this is the best way to describe it, but when I previously used bp_core_remove_nav_item('achievements'); it made the /members/username/achievements outside of the buddpress page. It basically created a new page that had nothing but a list of the user’s achievements. The part it called from the plugin code. It doesn’t show the username, avatar or anything else from buddypress.

    Also thanks for that update Shane.

    @screampuff

    Participant

    Thanks for that, the urrent_user_can('administrator') appears to be working as needed but current_user_can( 'manage_options' ) also works, I’ve switched to that.

    Do you have any idea how I can prevent users from manually entering http://mysite.com/members/username/achievements/ for username that is not theirs?

    @screampuff

    Participant

    Thanks for the reply. I made some changes to the code before reading and was able to accomplish removing the tab from buddypress profiles with this:

    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 );

    However I’m stuck on how to 404 the pages if they manually type out the URL

    In your code I see:

        // I guess we should 404 this page because this member isn't an admin or the displayed member.
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();

    How do I get this to apply only when it is http://mysite.com/members/<username>/achievements?

    @screampuff

    Participant

    I’m stupid, I was fooling around trying to find a way to prevent users from changing their display name and added some code:

    function disable_name_change( $data ) {					// Prevent users from changing display name
    if ( 1 == $data->field_id )
    $data->field_id = false;
    return $data;
    }
    add_action( 'xprofile_data_before_save', 'disable_name_change' );

    And this was causing it.

    I’ve resorted to just hiding the display name and field field in my theme’s css, so this is not necessary anyway.

    @screampuff

    Participant

    Anyone have any ideas?

    @screampuff

    Participant

    That worked perfectly in bp-custom.php

    Thanks for your help, I appreciate it!

    @screampuff

    Participant

    Created bp-custom.php with

    `define(‘BP_DEFAULT_COMPONENT’, ‘profile’ );’

    And I think the issue is that the link when you click your name from the dropdown in the WP toolbar (wp_admin_bar) has /edit/ at the end, so I will need to change that. Any idea where I would do that?

Viewing 14 replies - 1 through 14 (of 14 total)
Skip to toolbar