Skip to:
Content
Pages
Categories
Search
Top
Bottom

Where i

  • @whoaloic

    Participant

    Hello
    I have moved “Change Profile picture” to Settings tab with the following:

    function add_settings_subnav_tab() {
            global $bp;
            // rename general settings tab
            //$bp->bp_options_nav['settings']['general']['name'] = 'Account Details';
            // 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' );
            xprofile_screen_change_avatar();        
    }
    
    add_filter('xprofile_template_change_avatar', 'filter_changeavatar_template');
    function filter_changeavatar_template($template){
       
        return 'members/single/plugins';
    }
     
    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 );

    But I don’t have anymore the avatar-upload-form with the camera feature.
    How to put this in the members/single/profile/change-avatar.php file?

    Best wishes

Viewing 6 replies - 1 through 6 (of 6 total)
  • @danbp

    Participant

    Salut,

    the problem is that js is only loaded on the original modification page. To get the new UI, you have to use another filter.

    https://buddypress.trac.wordpress.org/browser/trunk/src/bp-core/bp-core-avatars.php#L1833

    Soufflé par @imath despite the heat (we :sweat: in Paris today)

    function change_profile_picture(){         
            add_action( 'bp_template_content', 'change_profile_picture_screen_content' );
    		xprofile_screen_change_avatar();   
    }
    add_filter('bp_avatar_is_front_edit', 'filter_changeavatar_template');

    You would probably also remove the original Change Avatar tab from Profile subnav ? Use this:

    function bpfr_remove_change_avatar_tab() {
    global $bp;
    	bp_core_remove_subnav_item( 'profile', 'change-avatar' );
    }
    add_action( 'bp_ready', 'bpfr_remove_change_avatar_tab', 15 );

    Have fun !

    @whoaloic

    Participant

    Thank you for the snippet Dan.
    I add to add_filter('bp_avatar_is_front_edit', 'filter_changeavatar_template'); to the change_profile_picture function and it works like a charm.

    @whoaloic

    Participant

    Ooops, the snippet adds a upload media zone to individual group tab settings.
    And disables the save button in this tab.

    @whoaloic

    Participant

    Here’s a solution:
    I have used template condition.

    /* add subnavs to existing tab*/
    function add_settings_subnav_tab() {
            global $bp;
            // rename general settings tab
            // remove profile menu tab
           // unset($bp->bp_nav['profile']);
            // add 'Change profile picture' sub-menu tab
            bp_core_new_subnav_item( array(
                    'name' => 'Photo du profil',
                    '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(){
       if (bp_is_my_profile()):
       add_action( 'bp_template_content', 'change_profile_picture_screen_content' );
        xprofile_screen_change_avatar();        
    endif;
    }
    
    add_filter('xprofile_template_change_avatar', 'filter_changeavatar_template');
    add_filter('bp_avatar_is_front_edit', 'filter_changeavatar_template'); // camera
    
     
    function filter_changeavatar_template($template){
        if (bp_is_my_profile()):  
        return 'members/single/plugins';
    	endif;
    }
     
     
    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 );

    @jessy-marco

    Participant

    How to customize “profile/change-avatar/” page?

    I have used “index-action-change-avatar.php” template, but javascript is not loaded and you can not crop image by your needs. I have copied all the content from /profile/change-avatar.php default buddypress template directory.

    Thank you.

    @jessy-marco

    Participant
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where i’ is closed to new replies.
Skip to toolbar