Embed Snippet on Your Site
MemberPress: Add Custom Field to Transactions Table
This code snippet will add data collected through a custom field on MemberPress registration forms to the transactions table at Dashboard > MemberPress > Transactions. The data will be added to the new custom column.
To use this code snippet, a custom field should be created at Dashboard > MemberPress > Settings > Fields tab.
The example code above adds the data collected using the custom field named Business Name. The slug of this custom MemberPress field is mepr_business_name. The custom field key used is col_business_name.
To modify the code and adjust it to any custom field, the field name and field key should be replaced on this line:
$cols['col_business_name'] = __('Business Name', 'memberpress');
To do this, Replace the col_business_name with the name of the actual custom field key with the col_prefix (e.g. col_your_key). Next, replace the dummy Business Name text with the name of the actual custom field or any other organizational name that should be used for this column.
Further, replace col_business_name with the same field key used above (e.g. col_your_key), and adjust the business_name to match the key used (e.g your_key). Apply these changes on the following line:
$cols['col_business_name'] = array('business_name', true);
Next, replace col_business_name with your field key on this line also:
if($column_name == 'col_business_name') {
Finally, replace the mepr_business_name slug with the slug of the actual custom field on this line:
$business_name = get_user_meta($user->ID, 'mepr_business_name', true);
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments