Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit users to only having one blog?


  • Kenneth Jensen
    Participant

    @kennethj

    Hi there

    Im pretty new to buddypress, but have worked with WP (and WPMU) quite some time.

    I have just set up a clean buddypress installation on kennethsblog.dk and is testing it out untill the right domain becomes available early in april.

    I would like to limit my users to having one blog only, and not the oppitunity to create more. Is there a way to do that? Or should I just comment out the option in adminbar.php?

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

  • Burt Adsit
    Participant

    @burtadsit

    https://buddypress.org/forums/topic.php?id=1328 see that topic for a solution Kenneth.


    Burt Adsit
    Participant

    @burtadsit

    Hmm. Where did that come from? Must be brand spanking new.

    I took a look at this issue and found that the wpmu functions such as get_blogs_of_user() return all blogs that a user has any capability in. That means that if I’m an author on some blog it reports back that blog also. The post i quoted above and the solution was for blogs *created* by a user. I couldn’t find any way other than looking in bp, which tracks blog creation and not just membership.

    wp doesn’t track blog creation, only blog capabilities. It couldn’t care less who created the blog. When sombody creates a blog they become an Administrator. The role Administrator doesn’t mean anything really. I can make somebody a blog admin and they never created the blog. bp tracks blog creation either through bp or wpmu.


    Kenneth Jensen
    Participant

    @kennethj

    Damn, thats some real fast answering there!

    Im trying out the plugin – thanks both of ya :)


    Kenneth Jensen
    Participant

    @kennethj

    Oh well, the joy didnt last that long.. :)

    After trying the plugin it seems that no mather how many blogs I permit, an already registrered user cant create a new blog. If a user, who has no blog but just a username, tries to create blog number 1 he/she gets the ‘Blog creation is closed’-message.

    Setting the number at the options-tab to 10 or 100 doesnt make a difference. Deleting the plugin-file makes it all work again.


    Burt Adsit
    Participant

    @burtadsit

    I haven\\\’t tried that plugin Kenneth. I do know that others have had success with the solution outlined in the forum topic above. It\\\’s just not the most elegant solution because bp doesn\\\’t have any hooks for blog creation right now. Gotta hack the theme.

    I thought I put in a ticket for a blog creation hook. Guess I didn\’t. I turned the red light on in this topic because I don’t have time to hunt down the best spot for a hook at the moment. I’ll lose track of this thread if it doesn’t stand out. Or somebody else could do it! (hint)


    Kenneth Jensen
    Participant

    @kennethj

    Thanks I’ll try to make the plugin work – just mailed the developer.

    Any help is of course greatly appreciated :)

    /K


    kennibc
    Participant

    @kennibc

    Please see this posting. I had the same question and this worked for me:

    https://buddypress.org/forums/topic.php?id=1629


    Aron Jay
    Participant

    @aronjay

    <?php

    /*

    Plugin name:Limit Blogs per User

    Plugin Author:Brajesh K. Singh

    Plugin URI:http://www.thinkinginwordpress.com/2009/03/limit-number-of-blogs-per-user-for-wordpress-mu-and-buddypress-websiteblog-network/

    Author URI:http://ThinkingInWordpress.com

    Version:1.0

    */

    add_filter(\”wpmu_active_signup\”,\”tiw_check_current_users_blog\”); //send fake/true enable or disabled request

    add_action(\”wpmu_options\”,\”tiw_display_options_form\”); //show the form to allow how many number of blogs per user

    add_action(\”update_wpmu_options\”,\”tiw_save_num_allowed_blogs\”);//action to save number of allowed blogs per user

    /****Check ,whether blog registration is allowed,and how many blogs per logged in user is allowed */

    function tiw_check_current_users_blog($active_signup)

    {

    if( !is_user_logged_in() )

    return $active_signup;//if the user is not logged in,do not change the site policies

    //otherwise…

    global $current_user;

    $blogs=get_blogs_of_user($current_user->ID);//get all blogs of user

    $number_of_blogs_per_user=tiw_num_allowed_blogs();//find

    //if number of allowed blog is greater than 0 and current user owns less number of blogs */

    if($number_of_blogs_per_user>0&&count($blogs)<$number_of_blogs_per_user)

    return $active_signup;

    else

    return \”none\”;

    }

    /****How many blogs are allowed per user *************/

    function tiw_num_allowed_blogs()

    {

    $num_allowed_blog=get_site_option(\”tiw_allowed_blogs_per_user\”);//find how many blogs are allowed

    if(!isset($num_allowed_blog))

    $num_allowed_blog=0;

    return $num_allowed_blog;//return the number of allowed blogs

    }

    /*****Show the Number of Blogs to restrict per user at the bottom of Site options ****/

    function tiw_display_options_form()

    {

    ?>

    <h3><?php _e(\’Limit Blog Registrations Per User\’) ?></h3>

    <table>

    <tbody>

    <tr valign=\”top\”>

    <th scope=\”row\”>Number of blogs allowed per User</th>

    <td>

    <input type=\”text\” name=\”num_allowed_blogs\” value=\”<?php echo tiw_num_allowed_blogs()?>\” />

    <p>If the Value is Zero, It indicates any number of blog is allowed</p>

    </td>

    </tr>

    </tbody>

    </table>

    <?php

    }

    /**************Save the Number of blogs per user when the form is updated **************/

    function tiw_save_num_allowed_blogs()

    {

    $allowed_number_of_blogs=intval($_POST[\”num_allowed_blogs\”]);//how many blogs the user has set

    //save to the database

    update_site_option(\”tiw_allowed_blogs_per_user\”,$allowed_number_of_blogs);//now update

    }

    ?>

    You can set the number of blog you would like to allow.. its not mine, just wanna share it.. :D

    – Aron

    EDIT: to set the number of blogs, proceed to Site Admin/Options/ then look below..

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Limit users to only having one blog?’ is closed to new replies.
Skip to toolbar