The MU forums have moved to WordPress.org

Set settings using programing (9 posts)

  1. zanfardinom
    Member
    Posted 14 years ago #

    Hi all,

    I am currently using WordPress MU 2.8.4. A little history.

    My main blog is blog.domain.tld. Then, I have subdomains listed as user.blog.domain.tld. I am trying to carry over settings that I set in the admin blog (blog.domain.tld) for each newly created sub blog.

    How do I set permalinks to custom (/%postname%/) for each new sub blog? Secondly, how do I set reading settings to static page (leave front page blank) and set blog page (based on a page I create dynamically)?

    I hope this makes sense.

    Thank you,
    Michael

  2. tdjcbe
    Member
    Posted 14 years ago #

    There's a number of ways to do it. Searching for 'new blog default settings' or even 'default permalinks' should pull up the previous discussions on the topic.

  3. zanfardinom
    Member
    Posted 14 years ago #

    Thanks, tdjcbe!

    I will try this. Is there a setting for

    <?php wp_list_pages('title_li=' ); ?>

    On my sub blog I want to show the pages for the admin blog. Is there a param that I can pass this that will show pages for admin only. I am using this for the header which has a navigation list of the pages for admin only.

    Michael

  4. DeannaS
    Member
    Posted 14 years ago #

    For setting the default permalinks (and a bunch of other defaults) you can use this plugin:

    New Blog Defaults

    for displaying the pages of one blog on another blog, you'd need to either write a plugin to show it in a widget or modify your theme. The gist of the code is:

    if (current_user_can('level_10')) {
       switch_to_blog(1); //whatever blog id you want to show pages from
       wp_list_pages('title_li=');
       restore_current_blog();
    }

    The level you're looking for will vary depending on who you want to see these. If you really want just the SITE admin, then use the function is_site_admin().

  5. zanfardinom
    Member
    Posted 14 years ago #

    Thank you, DeannaS!

    Works great. In my case I had to include this code on the theme in my header. Ok, I have seen the New Blog Defaults plugin, but how do you use it. I need to keep the admin settings the same for new blogs and users. One example would be the permalinks need to stay as custom = /%postname%/. Another example would be to include the same links for each user under the Links page.

    Thanks,
    mz

  6. DeannaS
    Member
    Posted 14 years ago #

  7. zanfardinom
    Member
    Posted 14 years ago #

    Thank you very much! I really appreciate your help and time. Great code.

    Where can I go to view all WP functions? I need to pass in the user name for the new blog, because one of the links will link back to the new blog homepage. i.e. http://username.domain.tld/.

    Do I just search the forums or is there an API page?

    mz

  8. andrea_r
    Moderator
    Posted 14 years ago #

    You want to insert the new blog's link into the blogroll upon creation?

  9. zanfardinom
    Member
    Posted 14 years ago #

    Thank you all for your help and quick response.

    I got it working with DeannaS code.

    function newblogd_blogroll_links( $blog_id, $user_id ) {
    	global $current_site;
        switch_to_blog($blog_id);
    	$addr = get_blogaddress_by_id($blog_id); //returns the new blog home address
        wp_delete_link(1); //delete Wordpress.com blogroll link
        wp_delete_link(2); //delete Wordpress.org blogroll link
    
    	// repeat this line for each link you want to include
        wp_insert_link(array('link_name' => 'Home', 'link_url' => '' $addr));
        wp_insert_link(array('link_name' => 'About', 'link_url' => 'http://username.domain.tld/about/'));
    
        restore_current_blog();
    }
    add_action( 'wpmu_new_blog', 'newblogd_blogroll_links', 10, 2 );

About this Topic

  • Started 14 years ago by zanfardinom
  • Latest reply from zanfardinom