Setting a Default Featured Image for Post Submissions

Would you like to set a default featured image for post submissions? By setting your own featured image for your submissions, you can easily control what image is set when you approve posts submitted through the Post Submission addon.

In this tutorial, we’ll share the custom PHP snippet you’ll need to add to set a default featured image in WPForms.


Creating Your Form

To start, you’ll need to create a new form or edit an existing one to access the form builder. For this tutorial, we suggest using our customizable Sample Post Submission form template to get started quickly.

If you need any help in creating this type of form, please review this documentation.

create your post submission form

Finding the Image ID Number

In order to set the default featured image, you’ll need to know the image ID number from your WordPress Media Library.

To retrieve this ID, log in to your WordPress dashboard and go to Media » Library. Then, hover over the image you’d like to use.

WordPress media library

At the bottom left corner of the page, you’ll see a URL. The number after the ‘post=’ is the ID for the image. For our example, this number is 2812.

find the image id number so that you can set a default featured image for every post submission

Note this number, as we’ll need it for the next steps.

Adding the Snippet

Now, it’s time to add the snippet to our site. To proceed, you’ll need to add the code snippet below to your site. If you need help with where and how to add snippets to your site, please check out this tutorial.

This snippet will only run on the form ID 463. You’ll need to update this ID to match your form ID. For any assistance in finding your form ID number, please visit this tutorial.

Note: Using this snippet means that all submissions with this form ID will have the exact same featured image set for each post.

Now, for each new post submission entry received, this snippet will set a default featured image.

Next, would you like to email the user submitting the form when the post is published? Take a look at our tutorial on how to send email notifications on Post Submission publish.

Action Reference: wpforms_post_submissions_process