• Resolved snarlybarley

    (@snarlybarley)


    On the /members page I have set up a grid view. I am wanting to edit the contents of the template such that I can take several fields and combine them ( street address, town, state, zip) so they display like “100 Main St., Anytown, NY 10101” instead of each field separately. However, I am having a hard time finding where I might echo field contents. Any help would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    Thread Starter snarlybarley

    (@snarlybarley)

    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

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Mod to Directory page & combining fields’ is closed to new replies.