Skip to:
Content
Pages
Categories
Search
Top
Bottom

Need a nudge in the right direction… customizing the settings page

  • @rebootnow

    Participant

    I’ve been staring at this for hours, and doing a few experiments, but I’m still none the wiser.

    I would like to customize the settings entry page more deeply than I can do by modifying “plugin-template.php” in the member theme. I would like to avoid modifying core files. I see that several folks have asked about this, but don’t see any replies.

    This much I know: The settings page content is created in “bp_core_screen_general_settings_content()” in “bp-core-settings.php”. I can do what I need to do by replacing this function.

    The question is how to do this. It seems that I need to change “bp_core_screen_general_settings()” so that it hooks my new function to ‘bp-template-content’.

    I see two ways to do this:

    1. I can replace “bp_core_add_settings_nav()” with a new function that adds a different subnav item. To do this I would remove_action() and then add_action() for my new function.
    2. I can create a new function that removes the old subnav items from the list and adds new ones that call my function.

    My question for both approaches is the same: what hook would I use to do this? Whatever I try, the old functions load, so somehow I’m not intercepting them correctly.

    Any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @r-a-y

    Keymaster

    Step 1 can be accomplished (I believe) with the following code:

    function override_bp_core_settings_nav{)
    remove_action('wp', 'bp_core_add_settings_nav',2);
    }
    add_action('init', 'override_bp_core_settings_nav');
    add_action('wp', 'YOUR_SETTINGS_NAV',2); // this is where you would add your new nav

    This is untested, but hopefully it gives you some pointers.

    @rebootnow

    Participant

    Ray, this is more than a pointer – it works as is. Awesome.

    Couple of questions for my ongoing education… it seems that ‘init’ is a WP hook after everything is initialized. So you are using it to ensure we replace the function *after* bp has added it?

    Secondly, is there a particular reason that you didn’t add the new function inside the override_bp_core_settings_nav() function?

    Thanks very much.

    @r-a-y

    Keymaster

    Regarding init (I copied this off a WP documentation blog, but explains what I want to say!):

    init is an action that is fired after everything in WP has been loaded, but before wp() has been run.

    So you’re right! In this case, because we want to override the wp hook, we’re using init to ensure that our function overrides BP’s one.

    For the second question, you could put the second add_action in the function and test it out. Like I said, the above code I posted was untested!

    Reason I left it out of the function was to ensure that our new settings nav function does indeed run, but in theory, it should work inside the override_bp_core_settings_nav() function as well (I think!).

    @rebootnow

    Participant

    Thanks again. This is really useful.

    BTW, the new function does work inside override_bp_core_settings_nav().

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need a nudge in the right direction… customizing the settings page’ is closed to new replies.
Skip to toolbar