WooCommerce Subscriptions Customization: Restore Additional Profile Field Added by PMP Register Helper

Can’t find a good title for this one. Here is the background. On a membership website, the membership feature was achieved by using Paid Membership Pro (PMP) plugin. An extra profile field was added using PMP Register Helper. Few months ago, a WooCommerce online store integration project brought in WooCommerce Subscriptions plugin to replace the membership purchase and recurring billing function which were provided by PMP. If you happen to be on the same boat, you know exactly what happens: The PMP check out page is replaced by WooCommerce checkout page. The additional profile filed is also bypassed.

The task: to restore the additional profile field using WooCommerce filter & hook.

First of all, here is the code to add the additional profile field using PMP Register Helper plugin.

The code shows how to add additional field called “New Member’s Name” in PMP. The additional field is saved in usermeta table, meta_key is “new_member_name”.

Because it can be and should be treated as part of user account information. I utilized an existing account field,Ā  just added a new variable called “new_member_name”.

Normally in WooCommerce, we should have form field validation upon form submission. In this case, “new_member_name” field is set to required (line 10), WooCommerce checkout page will take care of the validation. The warning message is pretty straightforward, “New Member’s Name is required.”

In case you would like to add some extra info, it can be achieved by using wc_add_notice() and “woocommerce_checkout_process” filter.

Final step, we need to save the user input. This is done by using “woocommerce_created_customer” action.

I am really impressed by how simple this could be done using just two hooks. In case you don’t have PMP & PMP Register Helper, but want to add extra profile filter, extra customization is needed to display it on user profile page.

Comments are closed.

Post Navigation