BuddyDev

Search

BuddyPress Simple Front End Post: A plugin to allow front end posting for the users

using-with-blog-categories

BuddyPress Simple Front End post plugin allows developer to create unlimited post forms for the front end posting. The current release includes support for custom posts type and categories but not the custom taxonomies. I will include custom taxonomy support in future.

I created this plugin to use with Blog categories with groups plugin as I could not find a nice solution for the purpose. Currently this plugin is aimed as developers. It has a simple api to create forms and to use them in theme. All the nasty works are handled by the plugin, so a developer does not need to dive into the code. Instead just use two lines of code to create a custom post form for any purpose they like.

Here is a screenshot of it being used with Blog Categories for groups plugin

Features:-

  • Allows to create  any number of customized post forms
  • supports custom post type
  • supports including a list of categories
  • has a very simple to use API for developers(I will show an example below)
  • It is very very Light weight

How to Use It:-

The basic philosophy is to allow developers to create an Instance of  ’BPSimpleBlogPostEditForm’ class for each of their form. This class handles the view and behavior both. Once you create an instance, you will need to register it to the ‘BPSimpleBlogPostEditor’ class(which is implemented as singleton pattern). Ok, so that seems nasty, right? No worries, you don’t need to delve into that. There are two api functions which will do it for you. You just need to pass the form name(which should be a unique name, it can contain spaces etc) and the basic sdettings of the form(like post type, allowed categories, who can write, who will be attributed as the author of the post and the post status).

Registering a Form Instance:-

To create and register a post form(with settings), you will need to use the following code


$form=bp_new_simple_blog_post_form($form_name,$settings);

The above code creates an instanace of ‘BPSimpleBlogPostEditForm’ class and registers it to the editor. You can create any number of forms you want. The above code must be called on/before bp_init action priority 10.

Here is a working example with the details of allowed parameters.


add_action('bp_init','my_post_form',4);//register a form
//it will register a fomr
function my_post_form(){
$settings=array('post_type'=>'post',//which post type
'post_author'=>  bp_loggedin_user_id(),//who will be the author of the submitted post
'post_status'=>'draft',//how the post should be saved, change it to 'publish' if you want to make the post published automatically
'current_user_can_post'=>  is_user_logged_in(),//who can post
'show_categories'=>true,//whether to show categories list or not, make sure to keep it true
'allowed_categories'=>array(1,2,3,4)//array of allowed categories which should be shown, use  get_all_category_ids() if you want to allow all categories
);

$form=bp_new_simple_blog_post_form('my form',$settings);//create a Form Instance and register it

}

You can modify any  parameter as you like. Even you can set it to allow non logged in users to submit post and save it to another user account.

The above code will register a new form with name ‘my form’ and you can retrieve it later at any point and show the form anywhere using the following code. We need to register the form on/before bp_init priority 10 to allow the controller to have access to this form. If you register the form after bp_init action, the controller will be unaware of the form’s existance and can not handle the save action.

Once a form is registered, you can show it anywhere you like using the following function.


//now let us  find the form and render it

$form=bp_get_simple_blog_post_form('my form');

if($form) //if this is a valid form
  $form->show();//it will show the form

You can use above code anywhere in your template to render the form.

Though registering the form on/before bp_init action may seem like a bad choice to some of you, It allows for server side validation of the credentials/authentication and thus helps from any misuse of the form.

It is a free plugin, please feel free to download it and use it on your custom projects. The Blog Categoris for groups plugin version 1.0.4 supports this plugin. You will simply need to activate this plugin and the plugin will work as the form handler for Bp Blog Categories.

Download Link:http://buddydev.com/plugins/bp-simple-front-end-post/

Code Repository: https://github.com/sbrajesh/bp-simple-front-end-post

Looking forward to hear your suggestions for the improvement of this plugin :)

Get latest WordPress & BuddyPress tutorials, news and tricks in your inbox.

We send out a lovely email newsletter with the most popular stories. Be a part of it.

39 Responses to BuddyPress Simple Front End Post: A plugin to allow front end posting for the users

  • Not sure about the purpose of this plugin… What does it do that you cannot do with Gravity Forms? (and for CPTs use the CPT plugin for Gravity Forms)
    What would really be cool is also to allow updating from the frontend. That is not built in with Gravity Forms (yet).

    • Hi Bente,
      Thank you for the comment.
      The gravitiy form is a versatile plugin and it may be doing this.

      I wrote this plugin to allow posting from front end for developers use, as no free plugin served the purpose. The current version is targeted at developers and not the site admins. I do plan to release an advanced version which will enable siteadmins to build the post form.

  • I can’t figure out how to install this plugin. It is a great plugin, but can you give me better instructions? Also, are you going to keep it updated?

  • Hey there, I’m a complete noob… been trying to find a solution to add a frontend post plugin, to allow buddypress members to post their own blog posts… I installed the plugin, however I can’t find the setup/options in the admin panel… i’m guessing i’m missing something here :X

    I’m guessing it has to do with all the code up there in your post… I was wondering if I could get a dummy version of how to activate this for my members?

    I would prefer to add this postbox with a category selection, and in the member’s profile area.

    a timely response would be greatly appreciated!

  • Thanks for this plugin!

    there is a way to add featured image in the form?

    • Hi Pajar,
      Thank you for the comment.

      Currently if you download it from github, you can specify the no. of images to be uploaded using upload_count parameter, But it won’t be set as featured image.

      I have got a local version working with custom post type/custom taxonomies/edit capabilities, will try to include the better uploading support when I make it available here.

      • Mate i spend many hours but didn’t figure out how to configure you’re plugin. I activate you’re plugin but don’t know that you’re above mentioned code where i have to place :s

        Can you guide me mate.

  • Hello,

    Thanks for the plugin. I have a question can I allow the users to add the featured image. If so then hows. Please give me any solution.
    Waiting of your reply

    Thanks

  • Thanks for the plugin. I can see in the screenshot you have hooked the plugin onto the Profile tabs. If possible provide the code for the same and I think you should include in your plugin by default. Thanks a lot again!

  • Is there an easy way to include a line for the tags in the Form?
    If that’s possible, this plugin looks like exactly what I need.

    • Hi Fritz,
      I have just pushed an update to github that does allows any taxonomy(including tags/custom taxonomies), any post type and custom fields. I will need to put a detailed doc though. Hoping to post a new tutorial tomorrow for the same.

  • Hi All,
    I have just released the BuddyBlog plugin today.
    Please check it here

    http://buddydev.com/buddypress/introducing-buddyblog-allow-users-to-blog-from-their-buddypress-profile/

    Will have a new post about the BuddyPress Simple Front End Post plugin in next 2-3 days, to explain about all the features of the front end posting.

  • I have installed front end posting as well as the BuddyBlog plugin. It doesn’t upload images. I have deactivated it until that can be fixed. Just thought I would let you know. :)

    • Hi Kevin,
      Thank you for reporting.

      Just tested the BuddyBlog again. It does upload the files. Please make sure your upload directory is writable and your theme lists attachment in the post.

      An enhancement in future will be show error if the upload is not complete.

  • Hi Brajesh, would it be possible to add some validation to both the Title and Post fields to help with SEO? It would be really good if there was a minimum chacter limit for both of these fields to force users to post meaningful titles and to limit posts under a certain amount of characters

    Is this possible please?

    Thanks
    Rob.

  • I still did not figure it out how to view images in post? Can you help me? And for the form registration where shall I put the above text? In which file?
    Thank you

  • Hi Brajesh

    I noticed that tags disappear from the post form once they have been used. I’ve raised an issue over at the GitHub repository which details the steps to go through in order to replicate the issue:
    https://github.com/sbrajesh/bp-simple-front-end-post/issues/3

  • Hi Brajesh

    Apologies, please close the GitHub issue, i’ve resolved the problem. Was a problem with my theme’s CSS.

  • Hi Brajesh on a different note, my bloggers have been asking how they can delete post comments via the front end. I notice there is a post delete button which they can use to delete the whole post. Is there a delete button for each comment?

  • Is there an example available which shows how to use custom fields with Simple Front End Post?

Leave a Reply

Are you looking for support?

Please join BuddyDev Premium Club to get timely support. At the moment, We are unable to provide much support in comments. By Joining BuddyDev Premium Club, you will get guaranteed support(and we have 30 days money back guarantee too).

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>