The MU forums have moved to WordPress.org

default role mu-plugin (solved) (4 posts)

  1. nicoa
    Member
    Posted 7 years ago #

    <?php
    /*
    Plugin Name: Add default role
    Plugin URI: http://www.netzbegruenung.de
    Description: This plugin adds a default role for new users to the blog they registered from. It takes the role from the "Default Role" setting at /wp-admin/wpmu-blogs.php
    */
    
    function netzgruen_add_default_role($userid) {
    
    global $current_site, $current_blog, $current_user, $user_id, $wpdb,$wpmuBaseTablePrefix;
    
    $domain = $current_site->domain;
    $path = $current_site->path;
    $blog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain = '$domain' AND path = '$path'" );
    
    $role = get_option('default_role');
    
    $cap_key = $wpmuBaseTablePrefix.$blog_id.'_capabilities';
    add_user_to_blog( $blog_id, $userid, $role );
    
    }
    
    add_action('wpmu_new_user', 'netzgruen_add_default_role');
    ?>

    works for me with subdirectory-setup...

  2. admire
    Member
    Posted 6 years ago #

    The plugin is working well for me. My only problem is that My "Create a new blog" link is points to the parent blog even when accessed from the sub-blogs. The link in the ../wp-content/themes/default/footer.php file domain . $current_site->path ?>wp-signup.php" title="Create a new blog">Create a new blog

    which always point to the parent parent blog. Can any one help so that that

  3. drmike
    Member
    Posted 6 years ago #

    Really wish folks would upload to http://wpmudevorg.wordpress.com and post a links. :)

    The forums here normally butcher code and pasting here is a risk.

  4. awacht
    Member
    Posted 6 years ago #

    I tried the aforementioned plugin and am finding it doesn't work for me. If I put it in mu-plugins it does work for the "master blog", but won't work for the sub-blogs (my goal) If I take it our of m-plugins and put it in plugins, then activate it per blog - it doesn't work at all. Any tips for this?

About this Topic