In this guide you will learn how to create and add custom fields to Paid Memberships Pro PDF Invoices. This can be anything from a value from a database table, post meta to user meta.

What Is A Custom Variable

A custom variable is similar to a WordPress shortcode, where it follows a specific layout standard and replaces this variable with dynamic data as previously mentioned. The custom variables follow the pattern of two opening curly braces, the keyword and then the two closing curly braces: {{example}}.

This data could be order data, tax, amounts or even user information.

Adding Custom Fields/Variables To PDF Templates

To add custom fields that aren’t tied to your WordPress user to the Paid Memberships Pro PDF Invoices Add On requires a bit of code and mapping data. Our code example should be able to help get you started so you can copy/paste and bring in some extra variables into your PDF templates and tweak further.

The Code Explained

The above code will get data from the order object, specifically the order notes and add it to a custom variable {{notes}}. As mentioned before, the code is only needed for all custom data that is not stored in user meta such as custom tables, order meta, CPT’s and so on.

In the screenshot below, this is an example of how to add a custom variable to the PDF editor for your custom fields.

Adding custom variable to PDF template via the visual template builder.

The output of the above example would be: “The user name is: Andrew”.

In this guide you should have learned how to create custom variables for Paid Memberships Pro PDF Invoices. If not, please reach out to our support for assistance as part of your purchase. This Add On does require Paid Memberships Pro to be installed in order to work correctly.