Mapping extensions
Extend the field mapping UI and value resolution without forking core templates.
Add source field options
PHP
add_filter( 'epc_mapping_source_fields', function ( $fields, $slug, $module ) {
if ( 'memberpress' !== $slug ) {
return $fields;
}
$fields['company'] = __( 'Company name', 'my-plugin' );
return $fields;
}, 10, 3 );
Add mapping modes
PHP
add_filter( 'epc_mapping_modes', function ( $modes, $slug, $module ) {
$modes['meta'] = __( 'User meta key', 'my-plugin' );
return $modes;
}, 10, 3 );
Saved as { "type": "meta", "value": "billing_company" }. Admin UI shows a text input for custom modes.
Resolve custom mode values
PHP
add_filter( 'epc_resolve_mapped_value', function ( $value, $entry, $source_values, $slug ) {
if ( '' !== $value || 'meta' !== ( $entry['type'] ?? '' ) ) {
return $value;
}
$meta_key = $entry['value'] ?? '';
$user_id = (int) ( $source_values['_user_id'] ?? 0 );
if ( $user_id && $meta_key ) {
return (string) get_user_meta( $user_id, $meta_key, true );
}
return '';
}, 10, 4 );
Normalize entries before sync
Filter epc_normalize_mapping_entry — return null to skip a field.
JavaScript
Modes and source fields are passed as epcAdmin.mappingModes and epcAdmin.sourceFields in the mapping modal.