Embed Snippet on Your Site
MemberPress: Add Custom Field Date to Members Table
This code snippet will add data collected through a custom field on MemberPress registration forms to the members' table at Dashboard > MemberPress > Members. 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 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 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['business_name'] = __('Business Name', 'memberpress');
To do this, Replace the business_name with the name of the actual custom field 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 business_name with the same field key used above, on this line:
if($column_name == '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