1. Home
  2. Knowledge Base
  3. Document Library Pro
  4. Advanced Usage

How to create advanced document upload forms with Gravity Forms

Document Library Pro comes with its own front end document upload form which allows people to submit documents to the library without needing to access the WordPress admin. This automatically includes the standard document fields which come with Document Library Pro, and meets the needs of most document libraries.

However, you may wish to create a custom document upload form if you need more advanced features such as:

  • Extra fields to send data to any custom fields or taxonomies that you have added to your documents.
  • Conditional logic to show/hide fields based on user selections.
  • Integration with payment gateways for paid submissions.
  • Custom workflows with notifications and approvals.
  • Advanced form validation and security settings.
  • Customizing the form layout, for example into multiple columns or pages.

To do all this, you can create a custom document upload form using the Gravity Forms plugin.

This article will explain how to:

  1. Set up a Gravity Form to collect document uploads and metadata.
  2. Automatically save submissions as documents in Document Library Pro.
  3. Allow administrators to approve new documents before they are added to the library.
  4. Display the submitted documents in a searchable, filterable document library.

Step 1: Create a custom document upload form

First, create a new form in Gravity Forms to allow users to submit documents.

  1. Go to Forms → Add New in your WordPress dashboard.
  2. Give your form a clear title, such as "Submit a Document".
  3. Add the following fields to your form:
    • Post Title field – This will be the document’s title.
    • Post Body (Content) field – A description of the document.
    • File Upload field – Users will upload their document here.
    • Document Categories (optional) – Use a dropdown or checkbox field for categorization.
    • Custom Fields (optional) – Use the "Post Custom Field" field type if needed.
    • Also add a field which people will use to add the actual document file. This depends on whether you want them to upload files to be stored in your WordPress Media Library, or whether they will enter the URL of a document which is stored elsewhere (e.g. on Dropbox or Google Drive):
      • Adding file uploads to the Media Library - Create a File Upload field.
      • Add a third party URL - Add either a Single Line Text field or Website URL field.
  4. Click 'Save Form'.
  5. Create a new page and embed the form using the Add Form button. This is the page where people will be able to submit new documents.

Tip – one form for both types of document: If you want to allow both uploads and external URLs in a single form, you can include two fields (one File Upload and one URL field) and use Gravity Forms' conditional logic to control which one is visible. For example, add a radio button asking the user to choose “Upload a file” vs “Enter a link,” and then show the appropriate field based on their choice. In the feed, map both fields to the Document’s File URL meta: the File Upload field for the upload case and the URL field for the link case. (Document Library Pro will use whichever value is provided. It’s a good idea to make one of those fields required and mutually exclusive via conditional logic, so that users don’t enter both.)

Step 2: Save form submissions as documents

By default, Gravity Forms saves submissions as standard posts. To save them as documents, you need to map each form fields to the corresponding field in the dlp_document post type. This is the 'Documents' post type created by Document Library Pro, and is used to store all the information about your documents.

You'll need to install and activate Gravity Forms' Advanced Post Creation add-on for this.

2.1 Map form fields to the Document post type

  1. Edit your Gravity Form and go to Settings → Post Creation.
  2. Click 'Add New' to create a Post Creation Feed.
  3. In the Post Type dropdown, select 'Document (dlp_document)'.
  4. In the Field Mappings section, map your form fields:
    • Title field → Post Title.
    • Body/Content field → Post Content (optional).
    • Category field → Document Categories.
    • Map any custom fields and taxonomies that you have added to your documents.
    • Also add a Custom Field mapping for the Document’s file URL field (_dlp_direct_link_url) and map it to whichever form field you're using to allow people to upload or add the URL of the actual document file (e.g. a PDF or Google Drive URL). Add another Custom Field for the file type with the name: _dlp_document_link_type and value "url".
  5. In the Post Options section:
    1. Set Post Status to Draft or Pending Review for moderation - 'or 'Published' if you don't need to check the documents before they're added to the library.
    2. (Optional) Assign the Post Author if you want to track who submitted the document.
  6. Click Save Feed to apply the settings.

Now, whenever a user submits a document, it will be saved as a draft document in Document Library Pro, ready for admin review.

2.2 Enabling admin email notifications (optional)

Gravity Forms can send an email alert whenever a form is submitted. In your form’s settings, go to the Notifications tab. By default, a new form includes an “Admin Notification” that is sent to the site administrator’s email address. You can edit this notification or create a new one.

Ensure that there is a notification email going out to the desired admin address when the form is submitted. This way, you (or whoever moderates the site) will instantly know when a new document has been added. You can then access the new submission in the 'Documents' section of the WordPress admin, make any changes, and click 'Publish'.

You can customize the notification email to include key details about the document submitted. For example, you might include the document title, the name or email of the person who submitted it, and perhaps a direct link to review the document in the WP dashboard.

Step 3: Display submitted documents

Once users submit documents, Document Library Pro will display them in your document library.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.