Forum Replies Created
-
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
Thanks, got it working with the language file!
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!
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 😉
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.
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?
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.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.
Thanks for that, the
urrent_user_can('administrator')
appears to be working as needed butcurrent_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?
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?
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.
Anyone have any ideas?
That worked perfectly in bp-custom.php
Thanks for your help, I appreciate it!
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?