Change Avatar --> Under Settings Tab

My BuddyPress site doesn't have any information except the user's name under their page's profile tab and I dont want anymore information here. I would like the hide/remove the profile tab from all users' profiles on the site but there is one problem:

The "Change Avatar" sub-nav item is under the Profile Tab and this option still needs to exist. Would someone help me remove/hide the profile tab but move the "Change Avatar" sub-nav item under the Settings tab instead?

Please respond as soon as possible. Thanks in advance.

  • signed_up

    Additional Resources:
    http://blog.maximusbusiness.com/2013/04/bp-profile-nav-positions-names/ ---> probably will help out with this, i couldn't interpret much of this due to limited coding abilities

    http://sensibleplugins.com/downloads/ --> this plugin might do the trick but not exactly sure if it has capabilities to remove/hide a natively existing tab (ex: profile tab) or move the subnav item to another tab... from descriptions of plugin, not so sure... Does anyone have experience with this plugin who can tell me if this is possible? I've used their contact form to ask question and will let you know on this forum thread what their response is.

  • Vaughan

    hiya

    the 2nd link you posted, sounds like it might work, but you might be best emailing the developers and actually asking them.

    i'm not sure your 1st link would suffice for this, it just changes the names & positions within their own tree. so you can't move them to another, at least i don't think.

    though you could try with this

    <?php
    function mb_settings_menu_tabs(){
    global $bp;
    $bp->bp_options_nav['settings']['change-avatar']['name'] = 'Change Profile Picture';
    }
    add_action('bp_setup_nav', 'mb_settings_menu_tabs', 201);
    ?>

    all being well that should add the avatar to the settings menu, if it works we can then go on and try and remove the profile menu.

    add the above code to a file called bp-custom.php & place this in the wp-content/plugins folder.

    hope this helps

  • signed_up

    @DavidM
    I'd rather not provide the theme that I'm using on the public forum thread, but it is a BuddyPress specific premium theme that I have customized a bit. If needed, I can send this info over via email or contact form.

    @Vaughan

    <?php
    function mb_settings_menu_tabs(){
    global $bp;
    $bp->bp_options_nav['settings']['change-avatar']['name'] = 'Change Profile Picture';
    }
    add_action('bp_setup_nav', 'mb_settings_menu_tabs', 201);
    ?>

    The code snippet didn't seem to have any effect (put in bp-custom.php), and btw, you can leave the part that changes "change avatar" text to "Change Profile Picture" because that was going to be the next thing that I was going to add to this task : )

    Anyways, if you think some temp. ftp account credentials, admin credentials, and site URLs would help out here, just let me know how to send them over (safely, obviously not forum thread) and I'll do so ASAP. Please respond soon. Thanks in advance!

  • DavidM

    Hi @signed_up,

    That's understandable, about the theme. I wasn't sure if this would involve a theme template customization. It doesn't though.

    The following gets us most of the way there:

    EDIT: See completed code below.

    The problem point is just getting xprofile_screen_change_avatar() to work within that section. Uncommenting the bp_get_template_part() function gets the avatar change section to load, but the feature itself isn't there.

    I'm looking into it. I've just not worked with BuddyPress templates enough to know how this is best done.

    Cheers,
    DavidM

  • signed_up

    @DavidM

    Okay, so the code is in fact hiding the profile tab and moving the change avatar (now, change profile pic) subnav under the Settings tab :slight_smile: ... but the subnav is acting a little oddly now... :slight_frown:

    This is sort of hard to explain and I'd rather not include a screenshot here, but it's doing something where under the subnav item (when clicked on) there is another frame of the menu under it... it's like repetition inside each other of the frame

    This may be something that you'd just need to take a look at and mess with it hands-on and I'd be happy to send over some temp. FTP and Admin Credentials. if that'd help. Tell me via a reply on this forum thread if that'd help... it may be just a bit of time before I get back to you with the creds because another WPMU Dev Staff Member is helping me out with something on my site as well and don't want to mix up the two issues (linked that thread below)
    https://premium.wpmudev.org/forums/topic/buddypress-verified-like-ribbon-on-certain-users-pages

    If you reply asking for the creds., I'll send them over via contact form as soon as the other issue is resolved. Please respond ASAP. Thanks in advance!

  • signed_up

    @DavidM

    Thanks! I really appreciate you looking into this and trying to help out here... I can email over my theme if that'd help... not sure exact rules on that though (maybe just send specific files?) since it's a premium theme so want to be careful not to violate anything...

    Anyways, if you need temp. credentials, just ask me... the other issue is resolved, so I can send at any time now. Try to get this taken care of as soon as you possibly can but since I'm not paying for custom coding (sry no budget), I'll give you your time and you have my patience... thank you!

  • DavidM

    Hi @signed_up,

    The following should sort this issue:

    function add_settings_subnav_tab() {
    	global $bp;
    	// remove profile menu tab
    	unset($bp->bp_nav['profile']);
     	// add 'Change profile picture' sub-menu tab
    	bp_core_new_subnav_item( array(
    		'name' => 'Change Profile Picture',
    		'slug' => 'change-profile-picture',
    		'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav['settings']['slug'] . '/',
    		'parent_slug' => $bp->bp_nav['settings']['slug'],
    		'screen_function' => 'change_profile_picture',
    		'position' => 30
    		)
    	);
    }
    
    function change_profile_picture(){
    	xprofile_screen_change_avatar();
    	add_action( 'bp_template_content', 'change_profile_picture_screen_content' );
    	return bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'members/single/home' ) );
    }
    
    function change_profile_picture_screen_content() {
    	return bp_get_template_part( 'members/single/profile/change-avatar' );
    }
    
    add_action( 'bp_setup_nav', 'add_settings_subnav_tab', 100 );

    The ordering of events just needed some adjustments. The xprofile_screen_change_avatar() function needed to precede the other content in the screen_function call.

    Cheers,
    DavidM

  • signed_up

    @DavidM

    Sorry for my late response, but seems like (even after purging caches everywhere), this code snippet still hasn't fixed the frame within frame issue... do you want me to send over some credentials for you to play around with the site a bit to see what's going on here? It's not live yet and all users are dummy ones so dont worry about crashing it :stuck_out_tongue:

    i can send over temp ftp and admin credentials + URLs via contact form if you provide specific instructions. Thank you!

  • DavidM

    Hi @signed_up,

    I actually found the problem to be related to BuddyPress-specific themes. I'm working on getting it sorted, just takes a moment.

    BuddyPress used to require Buddypress-specific themes but it's since been made compatible with other themes. Incidentally, the code works great on Twenty Thirteen, which is why I posted it, thinking it'd work as well with other themes.

    I'm working on it though, will post back once that's sorted. :slight_smile:

    Cheers,
    DavidM

  • DavidM

    Hi signed_up,

    I was avoiding copying all the original BuddyPress code that provides the functionality of the following method (it's a lot of code):
    xprofile_screen_change_avatar()

    But that copy-paste procedure might be necessary as there's something therein that makes the above snippet not work with some themes.

    For expediency here, you could copy that code yourself from xprofile_screen_change_avatar() into the code I provided and then find out which portion of it within it is causing it to not render properly.

    Meanwhile, I'm trying to nail that down myself without having to copy it all, though with limited time. It takes time though, to find where those types of conflicts occur. :slight_smile:

    Cheers,
    DavidM

  • signed_up

    @DavidM

    Sorry but I got a bit lost with all the copy and paste stuff of that method... probably due to my inexperience with coding in general. Once you have it sorted out (or ready for me to test), would you please post the entire code snippet that should be used? I really appreciate your help here and I understand that this is a little more complicated work, just asking that you try to get it to me as soon as you possibly can. Anyways, thanks and i hope to hear back soon :slight_smile:

  • DavidM

    Hi signed_up,

    Could you possibly let me know how the following works for you?

    function add_settings_subnav_tab() {
    	global $bp;
    	// remove profile menu tab
    	unset($bp->bp_nav['profile']);
     	// add 'Change profile picture' sub-menu tab
    	bp_core_new_subnav_item( array(
    		'name' => 'Change Profile Picture',
    		'slug' => 'change-profile-picture',
    		'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav['settings']['slug'] . '/',
    		'parent_slug' => $bp->bp_nav['settings']['slug'],
    		'screen_function' => 'change_profile_picture',
    		'position' => 30
    		)
    	);
    }
    
    function change_profile_picture(){
    	add_action( 'bp_template_content', 'change_profile_picture_screen_content' );
    	bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'members/single/plugins' ) );
    	xprofile_screen_change_avatar();
    }
    
    function change_profile_picture_screen_content() {
    	bp_get_template_part( 'members/single/profile/change-avatar' );
    }
    
    add_action( 'bp_setup_nav', 'add_settings_subnav_tab', 100 );

    In my tests, that snippet works in all but 1 theme, but it may just be that theme isn't quite up to WP theme standards.

    If it mostly works with your theme, I could just take it from there and see what more can be done.

    To be clear, the complicated part has solely to do with trying to utilize existing BP code and trying to move that into a different menu tab. Hopefully this one will just work for you.

    Cheers,
    DavidM

  • signed_up

    @DavidM

    Actually, just found an issue with the code...

    When testing if the code was doing its job, I only checked if the tab displayed correctly and visual stuff and never functionality. When I try to actually upload a new profile picture for a user, it seems as though the image is being uploaded but it doesn't take the user to the next screen of resizing/cropping the image or continue the process.

    Sorry for writing back to you on this thread after such a long time, I just found the issue though. Would you take a look at this? Please respond as soon as possible. Thanks in advance!

    FWI: The code that I am using is what you provided...
    http://pastebin.com/aD2Hp1TQ

    UPDATE: If it's easier for you to diagnose and resolve the issue by working directly on the site, just ask and provide instructions as to how you would like my site's URL & temporary FTP and admin credentials sent over.

  • signed_up

    @DavidM

    Would it be easier to troubleshoot hands-on with my website, so you don't have to worry about recreating my setup? The site is still under development per se, not all up and running (BP registration is closed), and all the users on it are dummy/test accounts, so making a tweaked code snippet temporarily crash the site isn't really an issue.

    I could send over my URLs and temporary FTP and admin creds via the WPMU Dev contact form if this is what you'd like (provide instructions for the subject of form submission and such).

    PS: That was just a suggestion. If it's easier for you to resolve this on your own setup locally, that's perfectly fine with me.

    Please respond as soon as possible. Thanks in advance!

  • signed_up

    I'll have a look back at this, but it will take a moment to get a good test setup where I can properly troubleshoot. I'll post back here right when I've got something on it.

    @DavidM
    Would you be able to provide an approximated time estimate as to how long it will take to diagnose and resolve the issue? My suggestion about working hands-on on my site was with the sole intent of speeding up the process, since you said it'd take a good bit of time to get a good testing setup together...

    Respond when you can. Thanks in advance!

  • signed_up

    I need help on this ASAP. Users on my site will suffer if this is not fixed.
    http://wordpress.org/plugins/buddypress-block-activity-stream-types/

    I recently started using this plugin to hide certain activity types from the activity stream on my site. It was working with most activity types perfectly fine. Recently, I added the "new_avatar" activity type to the list of blocked activity types... I'm not sure if this has anything to do with the issue, but now when I go to the "Change Profile Picture" subnav item under the "Settings" tab of my site (used to be "Change Avatar" under "Profile"), it just shows a blank white page instead.

    My site is just starting up and we have real users at the moment... dont want its reputation to be lost this early. I do not know when this issue started, so I;m not even sure if this is the cause... Ive been adding quite a bit of functions.php code recently as well...Thus, a staff member should probably diagnose this on my site and I'm willing to send over the credentials and URLs. Please respond ASAP.

    PS: That is the code that I finally started using. Site was working before with this code. Please resopnd ASAP with details that need to be sent over and how I need to send them over. Thank you. http://pastebin.com/ta67ezs0

    There is an error showing up in the error logs as follows:
    PHP Fatal error: Call to undefined function xprofile_screen_change_avatar() in .../plugins/bp-custom.php on line 32, referer: ...//settings/
    ... replaces part of the directories/urls for safety precautions since this is a public forum thread

    line 32 of bp-custom.php is xprofile_screen_change_avatar();
    That makes me remember that I also recently unchecked the "Extended Profiles" option that I thought I wasn't using on my site in BuddyPress settings. Went back and checked it and saved but issue continues. Please help!!!!

  • signed_up

    ... and this error in between then

    PHP Warning: Missing argument 2 for wpdb::prepare(), called in .../plugins/buddypress-block-activity-stream-types/admin/bp-activity-block-admin.php on line 6 and defined in /wp-includes/wp-db.php on line 992, referer: .../wp-admin/

    I have no clue what that is referring to and do not know how to completely unblock an activity. I need help as soon as possible. Thank you.

  • DavidM

    Hi @signed_up,

    Glad you were able to get that sorted and yeah, that plugin's old. Especially considering the recent updates to both WordPress and BuddyPress, older code like that is highly likely to have issues.

    Good to hear it's working now. Also glad to hear you got that prior issue sorted as well. I actually needed a local test site for various reasons, mostly for speed of testing. Great to hear you already got it resolved though.

    Cheers,
    David