Skip to:
Content
Pages
Categories
Search
Top
Bottom

Move subnav tabs


  • gingerbooch
    Participant

    @gingerbooch

    Hi there,

    I am working on bp-custom.php to move “change-avatar” and “change-cover-image” subnav tabs from User/Profile tab to User/Settings tab.
    In fact it’s not a move but disable tab/create new tab.

    It is working for “change-avatar” but the drag/drop script seems not loaded. Hopefully there is a fallback “browse/send” classic html form wich make it possible to add/delete the avatar.

    It is not working for “change-cover-image”. The page is working, the template shows the text but there is no form, no drag and drop. I suppose it is because this one has no html fallback in case the script’s loading fails.

    It’s like the template were looking for “profile” to be the actual page to authorize the script loading, while the actual page is now “settings”.
    I think I have to find the good function to copy/modify/rename it in my bp-custom.php , but I can’t find were those scripts are loaded.

    Any help would be greatly appreciated 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

  • Venutius
    Moderator

    @venutius

    It would help if you added your code, then we could see what you were trying to do and suggest alternatives.


    gingerbooch
    Participant

    @gingerbooch

    Hi @venutius,

    Thank you for your interest. I found a solution to get the avatar drag & drop to work from the change-avatar page moved to settings.

    I tried to apply the same logic for change-cover-image but it seems I need something more. At the moment the template loads well but there is no drag & drop neither any upload form.

    I want to post my code but I get this error : ERROR: Your reply cannot be created at this time.


    gingerbooch
    Participant

    @gingerbooch

    I can’t post my code here, first time it happens.

    Please check here : https://www.codepile.net/pile/Vy7L3YD2

    I think I miss something with bp-attachments, maybe related to xprofile / current component.


    Venutius
    Moderator

    @venutius

    Hi there, the cover image is not working due to the js for it not being loaded. try adding something like:

    function bpex_core_cover_image_scripts() {
    	global $bp;
    	if ( $bp->current_component != 'settings' ) {
    		return;
    	}
    	// Enqueue the Attachments scripts for the Cover Image UI.
    	bp_attachments_enqueue_scripts( 'BP_Attachment_Cover_Image' );
    }
    add_action( 'bp_enqueue_scripts', 'bpex_core_cover_image_scripts' );

    gingerbooch
    Participant

    @gingerbooch

    Hi @venutius,

    Thanks A LOT for your help !!! Your filter is awesome !!! 😀 😀

    – First I tried to copy/paste your code in mine, that made the change-cover-image feature fully working.

    – Then I removed the function and filter (wich I didn’t correctly used anyway lol …) : add_filter( 'bp_attachments_cover_image_is_edit', 'custom_attachments_cover_image_is_edit', 10, 2); and it was still working.

    – Then I saw change-avatar was not working anymore. I changed your condition to this one : if (! custom_is_user_change_cover_image() and the change-avatar is back.

    – Finally I tried to remove the function and filter : add_filter( 'bp_avatar_is_front_edit', 'custom_avatar_is_front_edit', 10, 1); and to reproduce your filter with BP_Attachment_Avatar but that did not work. There is a different filter for each one.

    I am a bit curious about this last point. Can you explain me why it is different please ?

    Thanks again I’m very grateful !! 😀


    gingerbooch
    Participant

    @gingerbooch

    Oh I can post code again !! Champagne !!


    gingerbooch
    Participant

    @gingerbooch

    The final code is :

    function custom_is_user_change_cover_image() {
    	global $bp;
    	return (bool) ( bp_is_settings_component() && bp_is_current_action( 'change-cover-image' ) );
    }
    
    function custom_bp_core_cover_image_scripts() {
    	global $bp;
    	if (! custom_is_user_change_cover_image()) {
    	return;
    	}
    	// Enqueue the Attachments scripts for the Cover Image UI.
    	bp_attachments_enqueue_scripts( 'BP_Attachment_Cover_Image' );
    }
    add_action( 'bp_enqueue_scripts', 'custom_bp_core_cover_image_scripts' );
Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar