Spring Sale! Save 30% on all books w/ code: PLANET24
Web Dev + WordPress + Security

WordPress Plugin: User Submitted Posts

[ User Submitted Posts ]

User Submitted Posts enables your visitors to submit posts and images from anywhere on your site via template tag or shortcode. User-submitted posts optionally include tags, categories, post titles, and more. You can set submitted posts as draft, publish immediately, or after some number of approved posts. Also enables users to upload multiple images when submitting a post. Everything super-easy to customize via Admin Settings page.

Update! Pro version of User Submitted Posts now available — check it out »

Let your visitors submit content

User Submitted Posts makes it easy to display a public post-submission form virtually anywhere on your site. Use the USP shortcode to display the submission form in any post or page, or use the USP template tag to include the form anywhere in your theme design. Visitors may then use the form to submit posts to your site. Depending on your preferences, user-submitted posts may include the following input fields:

  • Name
  • Email
  • URL
  • Post Title
  • Post Tags
  • Post Category
  • Post Content
  • Custom Field
  • Challenge Question
  • Google reCAPTCHA
  • Post Images

Using the Settings Page, you choose which fields to display, min/max number of images, min/max image size, redirect location, error messages and more. User Submitted Posts makes it easy to setup just about any type of user-submitted functionality for your WordPress-powered site. Here are some examples of how the USP plugin could be used:

  • Public Submit a Link form with tags
  • Simple Submit News form with post, title & author
  • Use as Contact Form that allows image attachments
  • Use as an Image Uploader, maybe with tags, title or whatever

Once a user has submitted a post, it’s saved as a “Draft” by default, but may optionally be set to “Publish Immediately” or even to publish if the author has “x” number of approved submissions. The plugin also displays a User Submitted Posts button at the top of the Posts Page that lets you filter all user-submitted posts/drafts with the click of a button.

Features

  • Let visitors submit posts from anywhere on your site
  • Use template tag or shortcode to display the form anywhere
  • Includes customizable captcha and hidden field to stop spam
  • Submitted posts may include any/all of the available fields
  • Redirect user anywhere after successful post submission
  • Includes template tags for displaying submitted content
  • New HTML5 submission form with streamlined CSS styles

Image Uploads

  • Optionally allow/require visitors to upload any number of images
  • Specify minimum and maximum width and height for uploaded images
  • Specicy min/max number of allowed image uploads for each post
  • Includes jQuery snippet for easy choosing of multiple images

Customization

  • Control which fields are displayed in the submission form
  • Choose which categories users are allowed to select
  • Assign submitted posts to any registered user
  • Customizable success, error, and upload messages
  • Plus options for the captcha, auto-publish, and redirect-URL
  • Choose form style: Classic, HTML5, or plain (disable styles)

Post Management

  • Custom Fields saved w/ each post: name, IP, URL, images, et al
  • Set submitted posts to any status: Draft, Publish, or Moderate
  • One-click post-filtering of submitted posts in the Admin Area
  • Includes template tags for easy display of submitted images

Installation & Usage

Overview

  1. Install USP just like any other WordPress plugin
  2. Go to the “User Submitted Posts” settings and customize your options
  3. Display the submission form on your page(s) using template tag or shortcode

Displaying the submission form

To display the form on a post or page, use the shortcode:

[user-submitted-posts]

To display the form anywhere in your theme, use the template tag:

<?php if (function_exists('user_submitted_posts')) user_submitted_posts(); ?>

Customizing the submission form

  • To style the submission form, use the included CSS file located at: /resources/usp.css
  • To add custom JavaScript, use the included JS file located at: /resources/usp.js

Customizing user-submitted posts

User-submitted posts are just like any other post, with the exception that they each contain a set of custom fields. The custom fields include extra information about the post:

  • is_submission – indicates that the post is in fact user-submitted
  • user_submit_image – URLs of any submitted images (one field per image)
  • user_submit_ip – the IP address of the submitted-post author
  • user_submit_name – the name of the submitted-post author
  • user_submit_url – the submitted URL

So when user-submitted posts are displayed on your website, say on the home page or single-view, these custom fields are available to you in your theme files. This enables you to customize the user-submitted posts by displaying the submitted name, URL, images, and so forth. Here are two articles for those new to using WordPress custom-fields:

Template Tags

Additionally, the USP plugin also includes a set of template tags for customizing your user-submitted posts:

usp_is_public_submission()
Returns a boolean value indicating whether the specified post is a public submission
Usage: <?php if (function_exists('usp_is_public_submission')) usp_is_public_submission(); ?>

usp_get_post_images()
Returns an array of URLs for the specified post image
Usage: <?php $images = usp_get_post_images(); foreach ($images as $image) { echo $image; } ?>

usp_post_attachments()
Prints the URLs for all post attachments.
Usage:  <?php if (function_exists('usp_post_attachments')) usp_post_attachments(); ?>
Syntax: <?php if (function_exists('usp_post_attachments')) usp_post_attachments($size, $beforeUrl, $afterUrl, $numberImages, $postId); ?>
Paramters:
    $size         = image size as thumbnail, medium, large or full -> default = full
    $beforeUrl    = text/markup displayed before the image URL     -> default = <img src="
    $afterUrl     = text/markup displayed after the image URL      -> default = " />
    $numberImages = the number of images to display for each post  -> default = false (display all)
    $postId       = an optional post ID to use                     -> default = uses global post

usp_author_link()
For public-submitted posts, this tag displays the author's name as a link (if URL provided) or plain text (if URL not provided)
For normal posts, this tag displays the author's name as a link to their author's post page
Usage: <?php if (function_exists('usp_author_link')) usp_author_link(); ?>

For more tags, check out USP at WordPress.org, and/or the source code of the plugin file located at: /library/template-tags.php

Screenshots

Here are some screenshots of the USP plugin:

Note: these screenshots were taken awhile ago. For fresh screenshots from more recent versions of the plugin, check out USP at WordPress.org.

Download & Demo

To download the free version of User Submitted Posts, visit the plugin homepage at the WordPress.org Plugin Directory.

About the Author
Jeff Starr = Creative thinker. Passionate about free and open Web.
SAC Pro: Unlimited chats.

120 responses to “WordPress Plugin: User Submitted Posts”

  1. Hi i tried this plugin in my blog. I find an error i wanna know how to fix it.

    In image upload there is link (Add another image) when i click it it taking me to top instead adding new box. But in your demo it add another box.

    How can i fix it so it add another box.

  2. I would love to see uploaded images go straight into the library so that I can add them where I want in the post.

    Is that possible?

    • I second this.

      Images should be uploaded as attachments, not as custom fields.

      And speaking of custom fields Jeff, have you considered allowing user defined custom fields?

      i.e. I have a classifieds site and want to use some custom fields in the form to let users select some options when submitting a post.

      Btw, here’s what I was working on lately.
      http://pastebin.com/1XAZvKz5

      It uploads the image as an attachment, sets the first uploaded image as the featured image and also, it checks the database to see if an exact post has already been submitted (not allowing the same post to be inserted again)

      Thanks for the plugin, I think I’ll mingle with it for a while :)

  3. silvercover 2011/03/07 6:22 am

    Thanks for this valuable plug-in. How can we fully localize this plug-in without tweaking php source. I mean using PO files. there are _e and __ functions but I don’t see any load_plugin_textdomain() function. what should I do?

    Thanks in Advance.

  4. Great plugin. one question though but it would be great enough if you guide us on without using plugin (you know better using too many plugins will burden your blog)

  5. First of all, great plugin. Just what I was looking for.

    Couple of things:

    Not sure whether there is actually a functionality already built in to restrict the upload-able file types? I’d like to restrict it to just .png and .jpg images, not sure how easy this is to build into the plugin, my PHP knowledge isn’t up to much.

    I’d also love a functionality to automatically set an uploaded image to be the featured image, the system i’m using sets featured images of posts as thumbnails on a gallery page, so at the moment using this plugin nothing appears in the thumbnail area.

    Would it be possible to modify the plugin to use a smaller (than real size) image in the post body, but when clicked, the user is taken to the original image size? I managed to edit the plugin to allow the uploaded images to be links to the isolated image file, but i’m looking to have the post body contain the uploaded image as a thumbnail, that when clicked will open up the full-size image (and with floatbox functionality, but that is a seperate issue and probably easy to work into the plugin).

    Once again thanks for a great plugin, I know its still in the early stages, so I hope you appreciate this feedback and consider adding some of these features into new releases :) in the meantime, if you have any idea how I can do any of the above, that would be great.

  6. I am very interested in using this plugin for a fundraiser site; is there a way to set the form where the site user posts text in the form fields, uploads one photo, and must make a payment using paypal before the post is submitted to the Admin for moderation/approval? Please advise, thank you!

  7. engin murat ?ahin 2011/03/08 7:12 am

    Hi dear Jeff

    How to add custom fields ?

  8. In follow up to my previous comment, I managed to fix some of the issues I outlined. However i’m having trouble automatically setting the uploaded image to be the ‘featured image’ (thumbnail) for the post.

    I’ve tried combining plugins such as Auto Post Thumbnail (http://www.sanisoft.com/blog/2010/04/19/wordpress-plugin-automatic-post-thumbnail/), which works great, but only if the image is actually embedded in the post content (ie, the post content field in the wordpress backend). As this plugin inserts the image as part of the loop as an ‘addition’ to the post’s content, the Auto Post Thumbnail doesn’t find the image to set as the featured image.

    I’m pretty sure it would be fairly simple to combine these two plugins by modifying this plugin so that the image code is actually embedded in the post’s content rather than inserted after using the template tag in the loop (so if you then went to edit a user submitted post in the wordpress backend, you’d see the code generated, and thus the image, by the template tag in the content field).

    Another way could be to somehow grab the first ‘gallery’ image (it would be the first image that is attached using this plugin) and set that automatically to the featured image. I couldn’t find a plugin or code to do this anywhere though.

    Seems a lot of people would like the image uploaded to be set as the featured image… Perhaps the plugin posted above could help you on your way to adding that into a future version. I’d try myself but I know almost nothing about coding :)

    • Jeff Starr 2011/03/08 8:56 am

      Thanks for all the ideas. I would jump on this like right now and add some of these requested features, but I’m extremely busy these days and don’t have a lot of extra time to pour into free plugins.

      If/when my schedule clears, I’ll maybe revisit USP and see what I can do. Until then, you can hire me at Monzilla Media for modifications, enhancements, and implementations.

      Thanks.

      • No problem. Would be great to see an update at some point, but it’s understandable that you have more important things to focus on than a free plugin such as this. I might get in touch with you RE some mods on the plugin, though it’s for a personal project so I don’t have a budget per se. I suspect it’s a fairly easy fix (an auto-set featured image functionality that is) for someone in the know with PHP etc, which isn’t me, but if I figure out of a quick fix I will post it up here for anyone else interested.
        Thanks

  9. I was wondering if I can use this plugin to allow the user to submit a custom post type instead of a normal post?

  10. WPUA.org - WordPress Users Association 2011/03/09 11:30 am

    Nice plugin!

    Would be good to have the input box be a WYSIWYG editor.

  11. Bonzy Salesman 2011/03/09 12:41 pm

    I also had a bit of trouble getting the images to display using the tags. So I wrote my own code to fetch the images. Include the following code within the loop in your single.php or page.php or any template file (or wrap it in a function):

    <?php global $wpdb;
         $query = "SELECT `ID`, `guid` FROM `$wpdb->posts` WHERE `post_type` = 'attachment' AND `post_parent` = '{$post->ID}'";
         $adimages = $wpdb->get_results($wpdb->prepare($query), OBJECT);
    // To display the first image.. ?>

    <img style="float: left; height: 100px;" src="<?php if(is_public_submission()){echo $adimages[0]->guid;} ?>" />

    <?php //And to display all the images...
         if($adimages) {
              foreach($adimages as $adimage) {
                   echo '<img style="border: 0px solid #E8E8E8; width: 110px;" src="' .$adimage->guid . '"/>';
                   //echo "<br />ID: " . $post->ID;
              }
         }
    ?>

    (The style tag isn’t necessary but you can use it to style your image and set height and width, etc).

    I hope that helps..

    • Bonzy, This is really fantastic, but I’m pretty inexperienced with handling code. I can see that the tag didn’t come through right, so I’m wary of using this.

      Isn’t there some way we can just get the plugin updated with these fixes??

    • Only just saw your code snippets Bonzy!

      Looks great, though like you said there is a problem with the code displaying properly on this comment thread. You can use https://pastebin.com/ to post snippets and link them, would massively appreciate it if you could do that just so that there won’t be any syntax errors when using them.

      The restricted form for logged-out users looks useful too, I was using a secondary widget to block my submission page from unregistered users before, but there were some issues with that so it would probably be much better to use your code. Where exactly does that need to go (what file+where)?

      Thanks massively in advance, this will be an amazing tweak to the plugin!

    • Thank you! This is exactly the problem I was having and this is a great solution. It would be great to see this optioned out in the plugin.

  12. Misunderstood what you were trying to do with your code, Bonzy, seems its just an alternative to using the code included with this plugin.

    Is there a way of using the template tag to append the image attachment’s code to the content field, instead of generating the image code within the loop of the page?

    To clarify, an example of the fields of the submission form, and then the generated output:

    Form
    field: Title
    field: Content/description (the main post content)
    field: Image upload

    Output
    field: Title (as usual)
    field: Content + [img src code linking to attached file URL]

    Of course, the image could be automatically appended before the user-entered text input in the content field, or after their text input.

    That way, no existing posts with normally placed images (‘img src’ code within the content field) have duplicates (as the loop generates another copy of the attached image to the post).

    I think this is fairly simple, just a case of shuffling some code around? This would also allow the featured image to automatically be set, as there are plugins which scan the post’s content for an image tag and automatically generate the post thumbnail (featured image) but these don’t work for images placed on a page via the loop.

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
The Tao of WordPress: Master the art of WordPress.
Thoughts
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Note to self: encrypting 500 GB of data on my iMac takes around 8 hours.
Getting back into things after a bit of a break. Currently 7° F outside. Chillz.
2024 is going to make 2020 look like a vacation. Prepare accordingly.
First snow of the year :)
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.