Close We have just updated BuddyDev for better performance. If you note a glitch, please let us know by using the feedback button on the left.

BuddyDev

Introducing BuddyBlog: Allow Users to blog from their BuddyPress Profile

Jotted by Brajesh Singh in Buddypress, Buddypress Free Plugins on February 18, 2013
18th Feb

Today, I am glad to finally introduce the BuddyBlog plugin. Currently, it is in basic phase and allows users of BuddyPress to blog, manage posts from their profile.

The basic functionality that it allows at the moment is:-

Basic Functionality:-

  • Creating New Post
  • Editing existing Post
  • Deleting Posts
  • Publishing Post
  • unpublishing post(moving to the draft status)

The current plugin supports following things:-

Features:-

  • Categories association to post
  • Tags association to post
  • Upload(can be limited , how many) on the post screen

Limitations:-

  • It is the initial release, so there may be some surprises(I am hoping there are none)
  • New categories/tags can not be created from front end(A limitation of simple front end post)

Dependency:-

This plugin allows users to create/manage posts from profile.

Here are a couple of screenshots to show the usage:-

Screenshots:-

Post Lists on Profile:-

when the user is logged in:-

Creating New Post:-

Editing Post:-

Currently, the best way to use it is having a community blog where everyone can post/edit their own post. The posts are listed as normal post on your blog.

You can use this plugin for custom post type too.

If you want to use it for custom post type, you will need to tell the plugin about this using  following code.

Using with Custom Post type:-


add_filter('buddyblog_get_post_type','buddyblog_my_post_type');

function buddyblog_my_post_type($post_type){

return 'custom_post_type';// it can be say 'events' or 'movies' or anything, just make sure you have already registered the post type

}

Also, if you are using custom taxonomy associated with the post type, you can tell buddyblog about it to output the custom taxonomy list(checkboxes/dropdown) on the new/edit page using the following


add_filter('buddyblog_post_form_settings','buddyblog_my_postform_settings');</pre>
/**
 * Filter on the Post form settings which is used by BP Simple Post Form settings
 * The settings array is structured like this
 * <code>
 * array(
 * 'post_type'=>buddyblog_get_posttype(),//do not change it, use the filter buddyblog_get_posttype to change it
 * 'post_status'=>'draft'//allowed values are draft|publish|inherit(any valid post status value)
 * 'tax'=>array(
 * 'taxonomy_name'=>array('taxonomy'=>'taxonomy_name',//taxonomy_name is the name of taxonomy e.g category, post_tag or your custom taxonomy
 * 'view_type'=>'checkbox',//valid values are checkbox|dd, it tell whether to list the taxonomy terms as checkbox or drop down
 * 'selected'=>array(termid1,termid2),//optional, if you want some terms to be selected by default
 * 'include'=>array(termid1, termid2,termid3)//if you want only these terms to be available to the user, user can select from these terms, if he does not select any terms, all of these terms will be associated to the post
 *
 * ),
 * 'another_taxonomy_name'=>array('taxonomy'=>'another_taxonomy_name',//another_taxonomy_name is the name of taxonomy e.g category, post_tag or your custom taxonomy
 * 'view_type'=>'dd'//valid values are checkbox|dd
 * )//you can add as many taxonomies as you want. Just make sure, the post type is allowed to have these taxonomies
 *
 *
 * ),//end of taxonomies
 * //use custom fields to allow as many custom fields as you want
 * 'custom_fields'=>array(
 * 'custom_field_key_name'=>array(
 * 'label'=>'What ever you want to display as the label for this custom field
 * 'type'=>'type of the custom field',//allowed values are hidden|select|radio|checkbox|textbox|textarea
 * ) 'options'=>array();//array of value=>Label use only for checkbox/radio/select
 * 'default'=>'some default value which is valid for current type'
 * //examples
 * 'privacy'=>array(
 * 'label'=>'Privacy',
 * 'required'=>true,
 * 'type'=>'select',
 * 'options'=>array(
 * array('label'=>'Anyone','value'=>'public'),
 * array('label'=>'Friends Only','value'=>'friendsonly'),
 * array('label'=>'Logged In Users Only','value'=>'loggedin'),
 *
 *
 * )//end of options dat
 * )//end of privacy custom field
 * ),//end of custom fields
 * 'upload_count'=>2;//how many attachments you want to allow with each post, It is a little bit misleading really
 * )//end of settings array
 * </code>
 *
 * @param array $settings is a multidimensional array explained above
 *
 */
function buddyblog_my_postform_settings($settings){

$settings=array(
 'post_type'=> buddyblog_get_posttype(),
 'post_status'=>'draft',//'publish'|'draft' etc

 'tax'=>array( //all the associated taxonomies, the below is settings for post category and post tag
 'category'=>array('taxonomy'=>'category',
 'view_type'=>'checkbox'
 ),
 'post_tag'=>array('taxonomy'=>'post_tag',
 'view_type'=>'checkbox'
 )

 ),
 'upload_count'=>2//how may uploads
 );

return $settings;

}

Please don’t get frightened by the above code. These are the settings for BuddyPress Simple Front End Post plugin version 1.1+. I will be posting a complete tutorial and more details about the new features of simple front end post plugin tomorrow.
If you don’t need custom post type/taxonomy, you don’t need to worry about these settings

Bonus:-

Since you have read my boringly written post, I seriously believe you deserve a dessert :)

Here is a sweet bonus, you can limit the no. of posts a user an publish:-

Limit no. of posts a User can publish:-


add_filter('buddyblog_limit_no_of_posts','__return_true');//yes, limit the no. of posts a user can publish

//if you activate limiting of the no. of published posts, the default limit is 100, good enough ? not happy, ok, let us read a little more

//let us set a limit on how many posts a user can publish

add_filter('buddyblog_allowed_posts_count','buddyblog_custom_limit_no_of_published_posts',10,2);
function buddyblog_custom_limit_no_of_published_posts($allowed_no_of_posts,$user_id){
//you can limit the no. of posts by filtering on the user id, say you can allow subscribers 10, contributors 100 and so on

return 20;//limit to 20 posts for everyone

}

Bonus 2:-

Do you want to show the single post view for posts created by user on user profile with comments and not as the normal post on site? Ok, no problem, here you go :)


add_filter('buddyblog_show_posts_on_profile','__return_true');

Do you want another bonus? why not visit us again tomorrow :)

And the final thing:-

The future Plans:-

  • Please let me know your suggestions
  • The Interface design/update for managing posts on user profile, I am really not a fan of what I have done at the moment
  • Better media uploader integration(Front End post editor, don’t know how to restrict the no. of uploads in that case)
  • Featured image integration(Front end post editor)
  • Ability to filter posts by status/categories on the my posts screen
  • Admin settings panel for the plugin(Have yet to decide what feature we may want to turn on/off, please do let me know your preferences)
  • anything you say :)

Download and Installation:-

Links: http://buddydev.com/plugins/buddyblog/

PS: Special thank to Selu, Mercime for the name of this plugin. The name was suggested by Selu and Mercime supported the idea. Thank you both for a great suggestion :)

Ok, That’s all we have got for today, why not visit us again tomorrow for some more tricks/tips/plugins . Don’t forget to let me know if you are using this plugin, whether you liked it, should we improve and anything you say :)

Related posts:

  1. BuddyPress Simple Front End Post: A plugin to allow front end posting for the users
  2. BP Redirect to profile Plugin :redirect Users to their profile on Login on buddypress sites
  3. Allow your users to change their Profile page background using BP Custom Background For User Profile Plugin
  4. Allow Users to select a blog theme while signing up/creating a blog on your buddypress powered social network
  5. Disable Blog Posts and new Blog Comments recording/tracking In the activity by BuddyPress

58 Responses to Introducing BuddyBlog: Allow Users to blog from their BuddyPress Profile

  • Very cool! Thank you. Will be testing this tonight on trunk versions of WP/BP :-)

  • Awesome!!! Thank u very much Brajesh :)

  • Hi Brajseh, looks really good. Can you add validation to the Title and Post fields that checks for a minimum character count please?. For example, members must create a title which is at least 30 characters long and their post must be at least 1000 characters.

    I think this would help with SEO and stop people posting one word titles and one sentence posts which happens a lot on my BuddyPress site. :(

    It would be great if these fields could be set by Admin at whatever character limit you like. Can you work your magic please :)

  • Hi Brajesh, any ideas when the minimum character count will be implemented? I really want to use this plugin as a replacement for ‘UCAN Post’, and this feature would be excellent for SEO.

    Also, what about checking the post title for duplicate posts with the same name? I recently discovered that I had flagged in ‘Webmasters Tools’ 40+ member generated posts on my site with the same title. Not good for SEO. For example http://domain.com/post http://www.domain.com/post-1 http://www.domain.com.post-3 etc etc. It would be great if BuddyBlog could check this before posting.

    As always, thanks

    Rob.

    • Hi Rob,
      I have just updated Bp simple front end post plugin. Please download version 1.1.2.
      Once you have activated this plugin(version 1.1.2), you can use the following code snippet in your bp-custom.php to limit the length of content/title

      
      add_filter('bsfep_validate_post','buddyblog_custom_validate_title_content',10,2);
      
      function buddyblog_custom_validate_title_content($is_error,$post_data){
          //if there is already an error, let us return
          if($is_error)
              return $is_error;
          
          
          //otherwise, let us check for the length of the title/contet
          $min_title_length=50;//assuming 50 characters
          $min_content_length=200;//assuming 200 charactes, will include space
          
          $title = trim($post_data['bp_simple_post_title']);
          $content = trim($post_data['bp_simple_post_text']);
        
          //get the form
           $form_id = $post_data['bp_simple_post_form_id'];
          
           $form = bp_get_simple_blog_post_form_by_id($form_id);
          
          if(strlen($title)<$min_title_length){
              
              $form->message=sprintf('Sorry, The title is too short. The title must be atleast %d characters long.',$min_title_length);
              $is_error=true;
              return $is_error;
          }
          
          if(strlen($content)<$min_content_length){
              $form->message=sprintf('Sorry, The content is too short. The post content must be atleast %d characters long.',$min_content_length);
              $is_error=true;
              return $is_error;
              
          }
              
          return $is_error;
      }
      
      

      Hope that helps.

  • Hi, it´s possible to use the rich editor (like tinymce) or only the html editor?

  • Hi Brajseh, thanks so much for this. The Title and Post character restriction work well.

    However, I’m having an issue adding a photo to the blog post. When I submit my post with a photo uploaded the post is visible but the image is not. Am I missing something here?

    Also, after the notification message appears informing you that the post has been successful, the input fields of the form still remain populated with the Title and Post content. Can these fields be cleared on a successful post please? Otherwise, I think my users will get confused and create duplicate entries…

    All the best
    Rob.

    • Did you find the solution to add media into post?
      Thanks

      Mari

    • Hi Rob,
      sorry for the delayed reply.

      Many people have asked the same question.

      The problem is I haven’t included the code in the template files to show image on post listing. I am hoping to put an update with the the template to list attachments today.

  • Hello, I need also help with uploads, it takes the images but it doesn’t upload them into post!
    Thank you

    • Hi Mari,
      I am sorry for all the confusions. The images are uploaded but not listed. We need to put the code in the template to list the attachments. will do something about it(I am trying even better to allow media uploader directly) in day or tow.

  • hi brajesh firstly heartly thanks for ur all contributions; n wanna ask that why is there 2 browse section for uploads n none of them seem working in buddypress 1.6.2

    • Hi Amir,
      Thank you for the comment.

      The media files are uploaded. The problem is attachments are not listed on the single post page. Can you please edit your single post and add the code to list attachments. That should make the media visible.

      • I did it by throwing this into single.php after the content.

        ‘ASC’,
        ‘post_type’ => ‘attachment’,
        ‘post_parent’ => $post->ID,
        ‘post_mime_type’ => ‘image’,
        ‘post_status’ => null,
        ‘numberposts’ => -1,
        );
        $attachments = get_posts($args);
        if ($attachments) {
        foreach ($attachments as $attachment) {
        echo wp_get_attachment_link($attachment->ID, ‘full’, false, false);
        }
        }
        ?>

  • Hi Brajesh, Nice plugin, will try this

    I would like to put up some suggestions,

    If you can create a dashboard where users can see their post views count and Analytics

    • Hi Saurabh,
      Thank you for the comment and the suggestion.

      You can use any post view counting plugin to count the post views and show it on the users profile. It should be pretty simple. Please do let me know if you find any issues. Will be glad to help :)

    • im using bp nicey theme and i edited the code in C:\wamp\www\wordpress\wp-content\plugins\buddyblog\template\buddyblog in single.php after

      ‘ASC’,
      ‘orderby’ => ‘menu_order’,
      ‘post_type’ => ‘attachment’,
      ‘post_parent’ => $post->ID,
      ‘post_mime_type’ => ‘image’,
      ‘post_status’ => null,
      ‘numberposts’ => -1,
      );
      $attachments = get_posts($args);
      if ($attachments) {
      $no_show=true;
      foreach ($attachments as $attachment) {
      if($no_show) {$no_show=false; continue; }
      echo wp_get_attachment_link($attachment->ID, ‘thumbnail’, false, false);
      }
      } ?>

  • Why do not you try to allow users to write a post for their group i mean registered users should be able to post their article in their joined groups. Everything is fine but if you will add this type of functionality so it will become very useful..
    One more thing posted article must be shown in that particular group activity stream.

    • Hi Kapil,
      Thank you for the comment.
      this plugin is intended for blogging from profile and not from group. I believe you may use either use BuddyPress group Blog or my Blog categories for Groups to achieve the same.

  • This would be really helpful

    if the member ( as in multisite) can post to her individual blog ( like elgg or oxwall org allows)
    if anyone can comment on a blog post BOTH from activity stream as well as the post itself like Buddypress Media

    • Hi Ron,
      That’s a very good idea.
      Here is the problem. How do we manage posts screen(I mean post listing screen) for the multiblog setup. If you can provide some idea on that, I will be glad to have this feature quickly. It is possible, the problem lies in managing the post screens.

    • Hi Ron,
      I was able to do it for the scenario when a user has only one blog, still not sure about users having multiple blog though.

  • Hello,
    I am experiencing issues with allowing users to upload media to their blog posts. I see their are two areas to upload but nothing shows up with the post. Has this been resolved? Thanks

  • This plugin just saved my 1700+ and growing userbase from extremely painful front-end blogging. We keep our users entirely out of the backend, so this plugin is just the thing for it. Awesome work. Looking forward to seeing it in the trunk.

    Question though: Is an “allow comments” toggle possible, too?

    • In fact after some testing with lots of members using it, buddyblog sometimes disables comments on a blog after an edit. Hard to replicate, though.

      We’d love a hint towards making a little hack for an “allow comments” tickbox on buddyblog>edit.

      On the other hand, blog deletion doesn’t work if members are completely denied access to the WP backend via other plugins, but I do have a completely unique lump of code that can do it. I’ll happily swap it for a comment toggle. :)

      • Hi Tom.
        Please update to BuddyBlog 1.0.1 and BP Simple Front End Post version 1.1.3 and you can control the comment status from the post new/edit screen.

        hope that helps.

        • Amazing. You made my 1900 users who all share a single-blog buddypress happy bloggers. :)

          I’d happily post my above no-backend-access delete hack here but it’s full of php. Care to take the conversation to email?

  • Hello,

    Thank you very much, this works great!!!

    Is there a way to redirect after login to the blog tab?

    Like, http://www.mysite.com/user/buddyblog/edit

    Thanks!

    Xander

  • Hi Brajesh,

    Can You give us a code hint, what code should be implemented to list the attachments in posts? I have also a trouble with images not showing up in posts.

    What code should go and where?

    Thanks

  • @all,
    for now, if you want to show the attachment with post, please use the code from this page

    http://codex.wordpress.org/Template_Tags/get_posts

    You will see the code to list that at the bottom of this page. You can put that in your single.php

  • Hi brajesh

    2 issues

    1. admin is unable to unpublish or edit or delete users post from frontend.
    2. can the post be restricted for admins approval? user submitted post as pending status?

    • Hi Saurabh,
      1. I had done that intentionally. Mostly, admins will be writing all sort of posts/pages and did not want it to be messed with Front end post. So, I did that intentionally. There is a filter, so if you really need it, please do let me know.

      2. Yes, can be done easily. Just filter on ‘buddyblog_post_form_settings’ and set post_status=’draft’. Also, you will need to filter on ‘buddyblog_user_can_publish’ and return false if user is not super admin. That will prevent users from publishing the post.

      Please do let me know if you need more help.

  • Brajesh, please help me, I still did not managed to show images in posts? I don’t know what shall I do, what code to insert where. I saw that you send me some comment link for fix, but I don’t know where to put the code, in which file.
    Thank you

    Marinela

  • Hi!

    Thanks so much for making this plugin. It’s exactly what we’ve been looking for in terms of giving members of our site the ability to post and create blogs from within their own profile.

    Not sure if this is a feature you are currently working on, but I was wondering if it was possible to have the blog post viewable within their own profiles in the same area where blog is listed? At the momment, when you click on a blog post, it brings you to a sperate blog post page outside the member’s profile. I would like to keep the experience within the same space as their profile if possible. So if member “Tanukid” were to link to one of their full blog post titled “Testing”, it would would direct them to the blog page in their profile located in:

    http://www.example.com/members/tanukid/buddyblog/testing/1234

    It would kind of be in the same style as say what they do at Giant Bomb for example :

    http://www.giantbomb.com/profile/pk_koopa/blog/the-speed-gamers-halloween-marathon-for-charity/71550/

    I know this is a pretty new and recent plugin, but that kind of functionality would make it perfect for what I’m looking for and would really help streamline the members page further. Greatly appreciate what you’re doing and look forward to the next updates, especially the integration of media manager and rich text editor. :)

    • Hi Sam,
      Thank you for the comment.
      If you read the blog post above, I have already provided code snippet to enable that future :)

      Hope that helps.

  • Hi,

    how can I use some particular category to select from front end, I am using this plugin and It shows all the category and tags, I just want 2-3 category to choose from frontend.

  • Any way to show a limited number of categories that the user can post to, i.e. if I have 4 categories, I want to show 3 but not the 4th?

  • Hi Brajesh,

    I found a Bug in BuddyBlog.
    When an user with role “Author” tried to edit a post from the backend the page refreshed instead of going to post edit page. So the user was not able to edit IS OWN posts from the backend but only the post written by other authors.

    I saw that in filters.php there is a function called buddyblog_fix_edit_post_link and also the relative filter option.

    So to fix this issue I had to modify the filter like this

    if (!current_user_can(‘edit_posts’)) {
    add_filter( ‘get_edit_post_link’,'buddyblog_fix_edit_post_link’,10,3);
    }

    So the EDIT LINK is edited only if the user doesn’t have the ability to edit posts.
    Doing like that the author now can edit own posts from the backend.

    I suggest to fix this in the future release!

  • Hi, I want to eliminate the capability of my buddypres users to attach image and archives in post, can you please help me saying me how?, thanks!!,

    • Hello, I asked for how to eliminate the capability of my buddypres users to attach image and archives in post, and I found the solution, in: bp-simple-front-end-post/form.php
      I eliminate this code after:

      <!— generating the file upload box –>

      <?php if($this->upload_count):?>

      <label> <?php _e(‘Uploads’,'bsfep’);?></label>

      <div class="bp_simple_post_uploads_input">
      <?php for($i=0;$i<$this->upload_count;$i++):?>
      <label><input type="file" name="bp_simple_post_upload_<?php echo $i;?>" /></label>
      <?php endfor;?>

      </div>
      <?php endif;?>

      Thanks for all, best plugin because simplicity!!!.

  • hi all, small Q: where/which php-file do i have to paste the code to activate the Custom Post Type for buddyblog/simple front end post? Thanks!!

    add_filter(‘buddyblog_get_post_type’,'buddyblog_my_post_type’);
     
    function buddyblog_my_post_type($post_type){
     
    return ‘custom_post_type’;// it can be say ‘events’ or ‘movies’ or anything, just make sure you have already registered the post type
     }

  • Hi Brajesh,
    Great work! forget my previous question – already fixed! :-)
    I’ve got another though – is it possible in any way to include custom post fields (text/radio/select) in the front end form? By means of easy coding or an integration of an existing form-customize plugin (Types for instance)? Would help out a lot!
    Thanx & best,
    Hendrik

  • Hi All,
    My apologies for not responding on this post about the problems earlier. I was busy with some work and was not able to support you. I am writing a post and will publish tomorrow that explains all the issues/solutions that you all have asked here.

    Thanks
    Brajesh

    • thanks! looking forward to them :-)

    • Welcome back Brajesh!

      Look forward to seeing to the post. Hopefully you will be able to help with the last few issues I’ve ran into. We’re getting so close to what we’re trying to achieve on our site.:D

  • Hi Brajesh!

    I hadn’t heard anything back regarding my last question in a while, I assume you’re just busy at the moment, but I thought I’d check back in to see if there has been any working solution regarding my issue. I greatly appreciate any help I can get on these issues.

    Thanks again!

Leave a Reply

Your email address will not be published. All the fields marked as * are required.


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>