Only one blog for user
-
Ciao everybody.
Simple question: is it possible to limit user to have one only blog (or none, obviously)?
Thanks
-
I could use this as well. Interested and hopeful for an easy answer.
Yes, this would be very handy feature!
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!
Yes, one blog for a registered user would be convenient!
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?
make a function:
if (a user has a blog)
return false
and then apply that do an action
(this is the basic concept)
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.
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!
@federichobo, Che culo!
Testing my Italian slang.
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?
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.
Works perfectly. Thanks Burt!
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.
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.
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!””
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.
Burtadsit, it’s funny and useful thing to mashup the languages and the slangs.
Alla prossima (see you next time)
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” 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!
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.
- The topic ‘Only one blog for user’ is closed to new replies.