Integration with a Post’s Metadata

by Jairo Niño | BuddyForms Form Builder

When we are creating a form in BuddyForms, whose purpose is to create or edit entries of a Post Type, sometimes we run into the situation that the post has one or more metadata. This metadata could be related to some post functionality that we also want to integrate in our form.

In most cases, these functionalities are implemented through themes or plugins, which use metadata as persistent variables to stock information related to the process or processes involved.

It’s important to mention that not all the metadata can be successfully integrated in BuddyForms. Depending on how these are being stocked in the database, we will know whether or not we can integrate them into our form. In general, if a metadata is stored as a serialized text string, it cannot be embedded, since each metadata must be associated with an input in the BuddyForms form.

What is Metadata?

The metadata is information associated to a post, users, comments and terms, which are generally used to constitute core functionalities, themes or plugins related to that type of data. This information can usually be modifiable from the user interface in the WordPress Administrator, for example, when creating or editing the entry of a publication in the Administrator, this information is usually introduced as a set of options, also called meta- box, which can be viewed or changed at any time by the user.

Note: A post Metadata is stored as an entry in the wp_postmeta table in the WordPress database

Use cases

Below we will present a series of use cases, using popular plugins as a reference, where it might be useful to integrate metadata with a BuddyForms form.

Note: The following examples may vary depending on the time and version of the plugin or related theme, they’re also practical examples that may not be applicable in certain contexts. Relevant research and testing is recommended to determine whether a use case is applicable to you or not.


Let’s suppose we want to create a BuddyForms form as simple as possible, which is able to edit or create functional WooCommerce products from the Front, with a series of predefined configurations in each product, having only the fields: Title, Content, Featured Image and Price (see Image 1).

The solution

It’s important to mention that besides BuddyForms, we need to have the BF WooCommerce Form Elements add-on installed to be able to carry out the example.

The first thing we’ll do is create a BuddyForms form with the required fields (see Image 1), including the WooCommerce fields (special field of BF WooCommerce Form Elements with the product options) and a price type field, which will be used to establish the product price. Finally we should have something similar to this:

The second thing we’ll do is to configure the WooCommerce field, so all the available options are hidden, in this way our form will be shown as in Image 1. The advantage of adding a WooCommerce type field with all the hidden options is that it allows us to predefine the setting that each product will have once it has been sent, without the need to “overload” the form with all the WooCommerce options.

As we need users to be able to set each product price created, we must configure the price type field (Regular Price) so when the product is sent, the metadata associated with the Regular Price field of that particular product is overwritten.

Note: WooCommerce uses Product as Post Type, which in conjunction with several metadata and taxonomies, defines the information for each product created.

The way to configure the Regular Price field or any other field that pretends to overwrite a metadata is very simple, we just have to set the field’s slug with a value that matches the metadata keyword (meta_key) that we want to overwrite.

Note: A way to obtain the meta_key of a metadata is by searching in the wp_postmeta table, if we know a post’s ID, we can perform a simple query to filter only the records associated with that Post. Another option is to search the documentation for the theme or plugin associated with the Post Type, generally this information is found in the section for developers. As a last option we could carry out an exhaustive inspection in the code, almost always this turns out to be the infallible option, but also the most laborious one.

Once the appropriate slug has been established for our price type field and our WooCommerce field configured, we can create or edit products from our BuddyForms form, with the price and other options specified in there.

Note: When adding new fields to overwrite a Post metadata, we must choose a field type that is consistent with the original field type used in the metadata displayed on the administrator page destined to create or edit an entry for that Post.

Events Calendar

Let’s suppose we want to create a BuddyForms form that allows us to create and edit events from the Front. Our form must have the fields: Title, Content, Start Date, End Record, Event URL. See Image 3.

The solution

As in the previous example, the first thing we must do is create a BuddyForms form, which contains the necessary fields shown in Image 3. After this we must identify and set the fields that will be used to be integrated into the metadata, in our case, they will be: Start Date, End Date and Event URL.

To configure these fields we must first identify the metadata that we want to integrate, besides that, we must determine if these are compatible with the integration. Then we must configure the slug of each field according to the meta_key of the corresponding metadata (see Image 4 and 5).

In the case of the Start Date and End Date fields, besides slug we must also configure the date format, so it matches the format used by the plugin when storing the information. The easiest way to identify the correct format is to inspect the wp_postmeta table for records that match the meta_key _EventEndDate or _EventStartDate. In this case, the date formats must be configured in the next way:

Note: As we mentioned above, these results may vary with time and version of the plugin, so they should be taken only as illustrative examples.

Once we have established the appropriate slugs and we have configured the date format for the Start Date and End Date fields, we’ll be ready to start creating or editing entries, if we need to add more fields, just repeat the aforementioned procedure.


As we have already seen, sometimes it’s beneficial to integrate the metadata of a Post Type in our BuddyForms form, we also saw how important it’s to know how the metadata is being stored in the database, to determine whether or not it’s embeddable in a BuddyForms form.

It’s important to note that each integration must be preceded by a corresponding investigation, since not in all cases an integration is applicable, sometimes a custom implementation may be necessary to complement the integration.

ThemeKraft offers the opportunity to create content for us. Guest Post


Submit a Comment

Your email address will not be published. Required fields are marked *

More from the Magazine

BuddyForms BuddyPress Members Benefits

Today we want to introduce you a special recommendation: BuddyForms BuddyPress Members, one of the best accessories you can find to make a social network in favor of your brand. BuddyPress Members benefits are superior to other similar plugins. It’s important to have...

Benefits of customizing your template with hook fields

Having an original website is possible even when working with templates, and it’s necessary to be able to focus on a target audience. So today we want to talk to you about the benefits of customizing your template with hook fields. Now why do we say it’s necessary in...

Top 5 most used BuddyForms extensions

Today we want to present to you the most used top 5 BuddyForms extensions by users looking to apply better development to their websites. Among these extensions there are some specials for content management and production, also for e-commerce, to improve the user...

What can you get with BuddyForms?

With the BuddyForms Plugin installed in WordPress you can configure 100% customizable contact, registration and publication forms for your website. If you have a project, where users need to create content on their page, it’s important to have a plugin for all the...

Why create a community for your business?

While it is true that in order to compete in the market you need to have a product or service as a solution for your potential customers, it is also true that without a community your business has no future. So start by asking yourself why create a community. First of...

Are you already using Content Marketing to grow your brand?

Currently there are many platforms on the Internet that can help your brand/business to generate content marketing to lead you to a positive income, there are even many virtual stores. To stand out on these Internet platforms we must attract the public and we can only...

The 5 keys to creating high-value content

Creating high-value content depends fundamentally on knowledge related to various aspects, such as your niche, your brand, interests, among others. In this article we are going to share the 5 keys to create valuable content with which you can attract potential...

MailPoet and BuddyForms

Creating a newsletter is an essential part of every online driven business and website. Nearly every website uses a newsletter to stay in contact with their audience, this is where MailPoet and BuddyForms comes in. Contact and registrations forms have a checkbox for...

How to speed up development

Development can be a stressful process. You have all these requirements you want and need to fulfill but also a fast-approaching deadline. It is also a process characterized by a lot of trial and error which on its own can take up a significant chunk of time. In every...

Pods in Change

We just recently released a new extension BuddyForms Pods and We've been quite excited about it. We did not know much about it until a customer asked us to support him and from the moment we understood it, we immediately became a fan of the Plugin. We have been...
Share This