WPForms Blog

WordPress Tutorials, Tips, and Resources to Help Grow Your Business

How to Use Custom Fields in User Submitted Posts

by Shahzad Saeed on Jul 3, 2017

Do you want to allow users to submit custom fields info through your WordPress forms? Custom fields is a powerful WordPress feature that allows you to store additional information related to your posts. In this tutorial, we’ll show you how to allow users to submit custom fields info using your WordPress forms.

What Are WordPress Custom Fields?

Custom fields, also referred to as post meta, is a form of metadata that allows you to store arbitrary info with every post, page and other post types. The WordPress themes and plugins that you installed on your site are already utilizing custom fields to add additional info with every post and page.

For example, if you’re using the Yoast SEO plugin on your site, it gives you a section to add SEO details like meta description and meta title to every post beneath the text editor. It is a perfect example of custom fields.

You can also find other additional sections in your post editor that are added by the theme or plugins installed on your site.

Similarly, you can manually add custom fields to every post and page to store any kind of information you want.

In your WordPress post editor, you can find the Custom Fields box beneath the text editor.

custom fields box

By default, custom fields are hidden in your page edit screen. You can make it visible by selecting the custom fields checkbox in Screen Options.

custom-fields-screen-option

For more details, you can read the complete guide to WordPress custom fields.

How to Allow Users to Submit Custom Fields

WPForms allows you to easily create a post submission form on your site, so your users can submit blog posts from the frontend of your site without logging into the admin area. You can decide whether submitted posts are automatically published, or pending review.

Additionally, you can also allow users to submit custom fields info using the post submission form.

There are many different use cases where you may want to allow users to submit custom fields. Some of them are:

  • Give full credit to guest authors: There’s no need to create an extra user profile for every guest post submission. Rather, you can easily change the author name for guest posts on your blog by utilizing custom fields.
  • Publish user submitted ratings: You can publish user submitted ratings for your product pages.
  • Or anything else you can think of.
This tutorial requires you to tweak your functions.php file. Make sure to backup your WordPress site before trying this tutorial on your production site.

As you can see, there are many possibilities to allow users to submit custom fields through your WordPress forms.

For the sake of this example, let’s take a look at how to credit guest authors on your blog by changing author names for guest articles.

Step 1: Create a Post Submission Form

The first thing you need to do is install and activate the WPForms plugin. Here’s a step by step guide on how to install a WordPress plugin.

In order to allow your audience to submit guest posts, you’ll need to install our Post Submissions addon. This addon makes it easy for users to submit guest articles or any other user-submitted content without logging into the admin area. You can learn how to install and use the post submissions addon here.

Then, you’ll need to have the guest post submission form created. You can easily create a user submission form by choosing the Blog Post Submission Form template.

blog post submission form

For more details on how to create and customize your post submission form, see our tutorial on how to create blog post submissions form as an example.

Step 2: Edit Custom Fields in WPForms

After creating the form, you need to customize the custom fields settings in your WPForms builder.

In your WPForms builder, click Settings in the left taskbar, and click Post Submissions. At the end of the page, you’ll find an option to add custom post meta.

In the Enter meta key field, enter guest-author. You can customize the key to make sense for your own form, but be sure to use hyphens instead of spaces.

In the next dropdown field, select Name. This is the corresponding field in your form that will be entered as a custom field.

custom post meta in wordpress forms

Don’t forget to save your changes when you’re done.

Step 3: Tweak Your WordPress Theme

Now that we’ve configured custom fields in the WPForms plugin, we need to tweak your functions.php file to replace the author name with the guest author’s name. For more information on how to do this, see this guide to pasting snippets from the web into WordPress.

One method to do this is to navigate to Appearance » Editor. Now find the functions.php file in the left hand side. Click on it and add the following code snippet.

Don’t forget to change guest-author if you’re using a different meta key.

function guest_author_name( $name ) {

global $post;

$author = get_post_meta( $post->ID, 'guest-author', true );

if ( $author )

$name = $author;

return $name;

}

See the screenshot below.

edit theme functions

Then click Update File.

Step 4: Publish Your Form

WPForms allows you to add your forms in various locations like your blog posts, pages, sidebar, and footers.

First, let’s take a look at the most common post/page embed option. Start by creating a new post or page in WordPress and then click on the Add Form button there.

Next, you need to select your form in the modal popup and click Add Form.

submit form

After that, simply publish your page and view it!

That’s it!

Whenever someone submits a guest post, the post author name will be automatically replaced with the guest author’s name.

With the post submissions addon, the possibilities are endless. You can create a user submitted events calendar and even clients booking form.

What are you waiting for? Get started with the most powerful WordPress forms plugin today.

If you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.