Skip to:
Content
Pages
Categories
Search
Top
Bottom

Only one blog for user


  • federicobo
    Participant

    @federicobo

    Ciao everybody.

    Simple question: is it possible to limit user to have one only blog (or none, obviously)?

    Thanks

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

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    I could use this as well. Interested and hopeful for an easy answer. :)

    Yes, this would be very handy feature!


    modemlooper
    Moderator

    @modemlooper

    instead of a full blown blog maybe a mini blog that can be posted to from profile

    Totally needed.

    I thought it would not be possible to add more than 1 blog until after i installed. was surprised to see it’s possible!


    Kevin Ryman
    Participant

    @kevinryman

    Yes, one blog for a registered user would be convenient!


    federicobo
    Participant

    @federicobo

    In this post (in WordPress MU forum) I’ve found a possible solution, but I’ve tried and seems not functioned (the user can again create more than one blog).

    Some feedback?

    https://mu.wordpress.org/forums/topic.php?id=5930


    nicolagreco
    Participant

    @nicolagreco

    make a function:

    if (a user has a blog)

    return false

    and then apply that do an action

    (this is the basic concept)


    Burt Adsit
    Participant

    @burtadsit

    OK people this seems to work. This requires modifying the member theme since I didn’t find any actions in bp to hook this into so here goes:

    In the member theme the file:

    /buddypress-member/blogs/create.php

    There is this chunk of code:

    <?php if ( bp_blog_signup_enabled() ) : ?>

    ..(some other stuff here)..

    <?php else: ?>

    <div id=”message” class=”info”>

    <p><?php _e( ‘Blog registration is currently disabled’, ‘buddypress’ ); ?></p>

    </div>

    <?php endif; ?>

    Replace the ..(some other stuff here).. with this:

    <?php

    global $bp;

    $blogs = bp_blogs_get_blogs_for_user($bp->loggedin_user->id);

    if (!$blogs)

    {

    bp_show_blog_signup_form();

    }

    else

    {

    ?>

    <div id=”message” class=”info”>

    <p><?php _e( ‘Limit one Blog per member’, ‘buddypress’ ); ?></p>

    </div>

    <?php

    }

    ?>

    This is the entire little create.php file in pastie: http://pastie.org/396083

    This was a: “quick ya we should have that and I’ve got to get to the store and get some boxes because I’m moving from Michigan where we have a snow storm today and Virginia where I’m moving to comes to a screeching halt when they get 1″ of snow and I gotta run now” solution.

    When I get back from the store I’ll help clean up the damage this might cause. This does work for me in a quick test.


    federicobo
    Participant

    @federicobo

    I’ve tested your solution,burtardsit, and seems work fine!

    This was a:”here, in the mediterranean italian coast, we have a sunny and not so cold day” thanks very much!


    Burt Adsit
    Participant

    @burtadsit

    @federichobo, Che culo!

    Testing my Italian slang.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Will this code allow a user to be added to a blog as a contributor still, and will it allow creation of a blog if they are a contributor to one already? :)


    Burt Adsit
    Participant

    @burtadsit

    That code checks the bp_user_blogs table to see if any blogs have been created for the user. It won’t care about the role a user has in an exiting blog. I checked ‘author’ and ‘administrator’ roles for a blog and it didn’t care. As long as you don’t create a blog for that user in either bp or wpmu backend looks like it ignores them because they haven’t created the blog.

    So I guess the answer is yes, John. You can still add users to blogs at any role you want and later on a user can still create a blog for themselves not matter what role they play in the mu blog network as long as they haven’t created a blog.

    This is really not the best mechanism to control this but I didn’t see the usual level of ‘actions’ and ‘filters’ in the blogs component that other areas of bp have. Gotta post an enhancement ticket in trac for that I guess.

    Works a treat.

    thanks loads.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Works perfectly. Thanks Burt!


    Burt Adsit
    Participant

    @burtadsit

    You betcha de nada.

    Hanging out here has caused my picture perfect English to degenerate into a mashup of American street slang and various foreign languages. Actually, I don’t consider that to be a bad thing. Of course this speaking ‘Burtlish’ could backfire on me. I think I said something like “you’re lucky!” to our Italian friend. I also could have said “you asshole!” if I’m not mistaken. :)


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    I know you know this already Burt, but being from Wisconsin and currently living in Miami, and let me tell you that moving out of the Midwest and getting some culture is definitely a good thing. :)


    nicolagreco
    Participant

    @nicolagreco

    You should use wordpress hooks to do that,

    but if it works that’s ok, but when will be the next update you’ve to hack the code again

    OT “haaah “Che culo!””


    Burt Adsit
    Participant

    @burtadsit

    Hey nicola, There are hooks for blog creation but wp doesn’t record the fact that ‘this user created this blog’. wp’s get_blogs_of_user() returns blogs where the user has any role. Being an ‘administrator’ in a user meta wp_BLOGID_capabilities list doesn’t mean the user created that blog.

    The creation process has to be recorded somewhere and the only place is in bp’s bp_user_blogs table. As far as I know. Be more than happy to learn otherwise. I learn something new every day around here. :)


    federicobo
    Participant

    @federicobo

    Burtadsit, it’s funny and useful thing to mashup the languages and the slangs.

    Alla prossima (see you next time)


    Korhan Ekinci
    Participant

    @korhanekinci

    Yes, it worked for me too, thanks!

    Accidentally, I found away to override this hack. When you are logged in, off course the “/register” link is invisible. But when you type it manually in the URL bar: as “http://mydomain.com/register&#8221; while logged in, it does however give you second chance to create a blog.

    It is ok for me, this hack is does the job.

    Don’t want to be a pain in the ass, just wanted to share my experience!


    madloki
    Participant

    @madloki

    Doesn´t work for 1.1!

    It doesn’t say it did! Make a new thread, this one minus the foreign languages is 6 months old.

Viewing 22 replies - 1 through 22 (of 22 total)
  • The topic ‘Only one blog for user’ is closed to new replies.
Skip to toolbar