Skip to:
Content
Pages
Categories
Search
Top
Bottom

Assigning default sidebar widgets

  • @mark235

    Participant

    I am using the standard BuddyPress home and member themes and wanted to assign default sidebar widgets. I am able to assign sidebar widgets to the left, center and right sidebars using a new file I called sidebarwidgets.php in the wp-content/mu-plugins directory. The code for in sidebarwidgets.php is:

    <?php

    function new_blogs_setting( $blog_id ) {

    add_option( ‘widget_categories’,

    array( ‘title’ => ‘My Categories’ ));

    add_option(“sidebars_widgets”,

    array(“sidebar-1” => array(“recent-posts”),

    “sidebar-2” => array(“categories”, “tag_cloud”),

    “sidebar-3” => array(“pages”, “links”)));

    }

    add_action(‘populate_options’, ‘new_blogs_setting’);

    ?>

    This works great and the setting is applied to all NEW blogs created after uploading sidebarwidgets.php. However, I can’t figure out how to create a default setting for the blog sidebar (sidebar-4). When I put in code with a similar syntax it causes the whole site to white screen. In the interim, users see a message asking them to add a widget to the blog sidebar, so they would have to add that manually.

    I am no programmer, so I am hoping someone wiser than I might be able to point me in the right direction. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • @mark235

    Participant

    Solved my own problem, here is correct code for assigning widgets for new blogs to all side bars:

    <?php

    function new_blogs_setting( $blog_id ) {

    add_option( ‘widget_categories’,

    array( ‘title’ => ‘My Categories’ ));

    add_option(“sidebars_widgets”,

    array(“sidebar-1” => array(“categories”),

    “sidebar-2” => array(“tag_cloud”),

    “sidebar-3” => array(“pages”, “links”),

    “sidebar-4” => array(“archives”)));

    }

    add_action(‘populate_options’, ‘new_blogs_setting’);

    ?>

    @burtadsit

    Participant

    Howdy. If you are playing in mu and new blog defaults and sidebars and bp and you actually succeed in accomplishing that, you certainly are a programmer. :)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Assigning default sidebar widgets’ is closed to new replies.
Skip to toolbar