WordPress.org

Plugin Directory

User Submitted Posts

User Submitted Posts enables your visitors to submit posts and images from anywhere on your site.

Overview

  1. Upload the /user-submitted-posts/ directory to your plugins folder and activate
  2. Go to the "User Submitted Posts" Settings Page and customize your options
  3. Display the submission form on your page(s) using template tag or shortcode

Important

NOTE that this plugin attaches uploaded images as custom fields to submitted posts. Attached images are not displayed automatically in posts, but rather may be displayed using template tags, either WP's built-in tags or the USP template tags (explained below). This provides maximum flexibility in terms of customizing the display of uploaded images.

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

There are three main ways of customizing the form:

  • Via the plugin settings, you can show/hide any field, customize options, and more
  • By adding a custom form template to the /custom/ directory, for example:
    • Add a custom form template: /custom/user-submitted-posts.php
    • Add a custom CSS stylesheet: /custom/usp.css
  • By using USP action/filter hooks (advanced):
Filters:
usp_post_status
usp_post_author
usp_form_shortcode
usp_mail_subject
usp_mail_message
usp_new_post
usp_input_validate

Actions
usp_submit_success
usp_submit_error
usp_insert_before
usp_insert_after
usp_files_before
usp_files_after
usp_current_page

More info about WordPress Actions and Filters

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 - the URL of the submitted image (one custom 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); ?>
Parameters:
    $size         = image size as thumbnail, medium, large or full -> default = full
    $beforeUrl    = text/markup displayed before the image URL     -> default = &lt;img src="
    $afterUrl     = text/markup displayed after the image URL      -> default = " /&gt;
    $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(); ?>

These template tags should work out of the box when included in your theme template file(s). Keep in mind that for some of the tags to work, there must be some existing submitted posts and/or images available.

For more information, check out the template-tag file at: /library/template-tags.php

Additional Notes

Here's a quick tutorial for automatically setting submitted images as featured images (aka post thumbnails).

Requires: 3.8 or higher
Compatible up to: 4.1.1
Last Updated: 2015-3-22
Active Installs: 10,000+

Ratings

4.3 out of 5 stars

Support

21 of 26 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1
29,7,2
100,1,1
0,1,0
33,3,1
50,2,1
50,4,2
43,7,3
50,2,1
100,3,3
0,1,0
0,1,0
100,3,3 100,2,2 100,1,1 100,1,1
100,1,1 100,1,1
100,1,1
100,1,1 100,2,2
100,4,4
100,3,3
100,1,1 100,3,3
100,1,1
100,2,2 100,1,1
100,1,1
100,4,4
100,2,2 100,1,1 50,2,1
0,1,0
50,2,1
100,1,1 100,1,1