Plugin Support
Yurii
(@yuriinalivaiko)
Hello @snarlybarley
You can use the “Show tagline below profile name” and “Choose field(s) to display in tagline” setting on to add fields to the profile cards in the member directory. See details here: https://docs.ultimatemember.com/article/1513-member-directories-2-1-0#card
You can use the um_ajax_get_members_data hook to modify and format field’s value when it comes to the member directory.
Use this code as an example. Change the field keys to the ones you need.
// Format address to display in the directory.
function custom_um_ajax_get_members_data( $data_array, $user_id ) {
// Enter the field meta_key from the "Choose field(s) to display in tagline" setting here.
$key = 'billing_address_2';
// get street address, town, state, zip.
$street = UM()->fields()->field_value( 'billing_address_1' );
$town = UM()->fields()->field_value( 'billing_city' );
$state = UM()->fields()->field_value( 'billing_state' );
$postcode = UM()->fields()->field_value( 'billing_postcode' );
$address_parts = compact( 'street', 'town', 'state', 'postcode' );
$data_array[ $key ] = implode( ', ', array_filter( $address_parts ) );
return $data_array;
}
add_filter( 'um_ajax_get_members_data', 'custom_um_ajax_get_members_data', 10, 2 );
Regards
Wonderful, hugely helpful. Thanks!
Plugin Support
Yurii
(@yuriinalivaiko)
Hi snarlybarley
Thank you for getting back with feedback.We’re going to go ahead and mark this thread Resolved.
Please feel free to re-open this thread if any other questions come up and we’d be happy to help.
Regards