Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • mariochampion
    Participant

    @mariochampion

    one quick update:
    the double add_action is actually taken from an example at bp-core-settings.php (in the bp_core_add_settings_nav() function) NOT bp-xprofile.php, which does in fact use bp_setup_nav to hook into for setting up profile nav/sub-nav items.

    my guess is bp_core_new_subnav_item adds to an array, and includes a dupe check to the array (if !array_key_exists or some such) because the sub-nav items only show once…

    ahh, hooks — a bit like magic!


    mariochampion
    Participant

    @mariochampion

    just to add to this discussion, concerning what hook to link it to…this is what works for me. i didnt have luck with bp_setup_nav for some reason. i dont recall where i got this example, but think its bp-xprofile.php itself. this worked in both theme>functions.php and in my own mmc_functions.php which i “require()” in functions.php

    just to add a hint of background, we are moving these two items to the ‘settings’ tab from the profile tab. the removing is trivial, the adding is trivial, the getting all the right functions/themes/forms called, not so much. but its done and it works.

    here is the code for removing sub-tabs — aka options:

    `
    //removes in a structural way.. no change to bp-xprofile.php

    function mmc_bpsetupnav_removefromprofile(){
    global $bp;

    if ( $bp->current_component == $bp->profile->slug ) {
    bp_core_remove_subnav_item($bp->profile->slug, ‘edit’);
    bp_core_remove_subnav_item($bp->profile->slug, ‘change-avatar’);

    }//end if
    }//end function
    add_action( ‘wp’, ‘mmc_bpsetupnav_removefromprofile’, 2 );
    `

    here is my code for adding them to the settings tab

    `
    ////////////////////////////////////////////////////////////
    ////// functions for moving to Settings tab the editprofile/change avatar sub-tabs

    function mmc_bpsetupnav_forsettings(){
    global $bp;

    if ( $bp->current_component == $bp->settings->slug ) {
    //define ( ‘BP_XPROFILE_SLUG’, ‘settings’ );//didnt have desirable effects. left her for documentation

    //this is essentially a clone of xprofile-settings.php, but with tweaks to change BP_XPROFILE_SLUG references tp BP_SETTINGS_SLUG
    //that way didnt change any core files, and moved it out of the upgrade stream
    require_once( WP_PLUGIN_DIR.’/mmc_misc/functions_xprof_settings_mmc.php’);

    $profile_link = $bp->loggedin_user->domain . $bp->profile->slug . ‘/’;
    $settings_link = $bp->loggedin_user->domain . $bp->settings->slug . ‘/’;

    //EDIT PROFILE
    bp_core_new_subnav_item( array(
    ‘name’ => __( ‘Edit Profile’, ‘buddypress’ ),
    ‘slug’ => ‘edit’,
    ‘parent_url’ => $settings_link,
    //’parent_slug’ => $bp->profile->slug, //left for documentation
    ‘parent_slug’ => $bp->settings->slug,
    ‘screen_function’ => ‘xprofile_screen_edit_profile_mmc’,
    ‘position’ => 50, //magic number based on current items already there in SETTINGS tab
    ‘user_has_access’ => bp_is_my_profile() //ADDED, NOT IN ORIGINAL WHEN IN BP-XPROFILE.PHP
    ) );

    //CHANGE AVATAR
    bp_core_new_subnav_item( array(
    ‘name’ => __( ‘Change Avatar’, ‘buddypress’ ),
    ‘slug’ => ‘change-avatar’,
    ‘parent_url’ => $settings_link,
    //’parent_slug’ => $bp->profile->slug, //left for documentation
    ‘parent_slug’ => $bp->settings->slug,
    ‘screen_function’ => ‘xprofile_screen_change_avatar_mmc’,
    ‘position’ => 60, //magic number based on current items already there in SETTINGS tab
    ‘user_has_access’ => bp_is_my_profile() //ADDED, NOT IN ORIGINAL WHEN IN BP-XPROFILE.PHP
    ) );

    }//end if

    }//end function
    add_action( ‘wp’, ‘mmc_bpsetupnav_forsettings’, 2 );
    add_action( ‘admin_menu’, ‘mmc_bpsetupnav_forsettings’, 2 );
    `

    note the TWO add-actions at the end. also taken from example at bp-xprofile.php. why this and not bp_setup_nav.. i dont know!

    ggod luck
    mario


    mariochampion
    Participant

    @mariochampion

    woohoo, and happy to help where i could!

    and, ya know, reading the tracticket i see a comment about making it conditional to textbox types only. i actually spent a bit of time trying to figure that out, but, i didnt know how to pass the right $this->type value from the object in the BP_XPROFILE_somethingortheother class without adding a line to that file. that is, i couldnt seem to get to it from add_actions/add_filter permutations… so i hoped that wp_filter_kses() would gracefully handle radio btns, checkboxes, etc

    thanks to all yall for so much good work.
    adios
    mario

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