• Resolved wesmed

    (@wesmed)


    Hello, I am trying to figure out how to shorten the text within the Ultimate Member filter fields. In short, the profile forms that I’ve set up are mostly custom fields and due to the nature of the forms’ questions, they require more words than your typical form questions. Only problem is that the filters take up half the page because the labels of the form fields are lengthy.

    To give an example, one of the profile questions asks, “Does the property include any of the following equipment or infrastructure? (Select all that apply)”, but I am trying to figure our how to shorten the text of the filter field/dropdown that appears on the “Members” page to just say “infrastructure”, for example. I’ve tried shortening the Ultimate Member form “labels” and then including the full/longer question in the “placeholder” or “default text”, and while this solves the length of the text in the filter fields, the full/longer question is not readily visible when users fill out the profile form. Hopefully this isn’t too confusing. Can anyone help me with this?

Viewing 14 replies - 1 through 14 (of 14 total)
  • @wesmed

    You can try to use the template customization for Members Directory.
    In this case you can use the members.php template.

    https://docs.ultimatemember.com/article/1516-templates-map

    After you have copied the template file to
    wp-content/themes/{active_theme}/ultimate-member/templates/

    you can customize the template by adding your code after line 330 like this for select filters:

    <?php
    	$long_title = '';
    	if ( $type == 'select' ) {
    		if( $filter == 'gender' ) {
    			$long_title = 'title="Long title for gender"';
    		}
    		if( $filter == 'country' ) {
    			$long_title = 'title="Long title for country"';
    		}
    	}?>

    Change gender and country to your filters and the Long title for gender etc.
    Duplicate the if statement for additional select filters.

    Finally include your $long_title content in the filter’s div

    <div <?php echo $long_title?> class="um-search-filter um-<?php echo .....

    Edit: Line 330 contains:

    $type = UM()->member_directory()->filter_types[ $filter ]; ?>

    • This reply was modified 1 year, 6 months ago by missveronica.
    Thread Starter wesmed

    (@wesmed)

    Thank you for the response missveronica!! I’ve only recently started altering files/code, so pardon me for my ignorance, but once I go to wp-content/themes/{active_theme} (which is Divi), I cannot find /ultimate-member/templates in order to paste the members.php template. Am I missing something? Does it need to be in this exact order for locating the file?

    @wesmed

    I cannot find /ultimate-member/templates in order to paste the members.php template.

    You must create the folders with the file manager or your FTP client.

    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hello @wesmed

    You can use the um_search_fields hook to override labels in the member directory filters.

    A code example:

    add_filter( 'um_search_fields', function( $attrs, $field_key, $form_id ) {
    
    	if ( 'Does the property include any of the following equipment or infrastructure? (Select all that apply)' === $attrs['label'] ) {
    		$attrs['label'] = 'Infrastructure';
    	}
    
    	if ( 'Your favourite sport activity (Multi-Select)' === $attrs['label'] ) {
    		$attrs['label'] = 'Favourite sport';
    	}
    
    	return $attrs;
    }, 10, 3 );

    You can add custom PHP code to the functions.php file in the active theme directory.

    Regards

    Plugin Support andrewshu

    (@andrewshu)

    Hi @wesmed

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards

    Thread Starter wesmed

    (@wesmed)

    Hello, I just returned from my honeymoon so I apologize for the absence! @missveronicatv thank you so much for your assistance. I was able to create the folders and copied the “members.php” template into a directory within my theme.

    The file structure is now: wp-content/themes/Divi/ultimate-member/templates/members.php

    Below is the code example you originally provided (just for a quick reference), and below that, you will find my modifications bolded and <span style=”text-decoration: underline;”>underlined</span> text according to how I understood your instructions. Would you be so kind as to see if I am understanding your steps properly?

    <?php
    	$long_title = '';
    	if ( $type == 'select' ) {
    		if( $filter == 'gender' ) {
    			$long_title = 'title="Long title for gender"';
    		}
    		if( $filter == 'country' ) {
    			$long_title = 'title="Long title for country"';
    		}
    	}?>
    <?php
    	$long_title = '';
    	if ( $type == 'select' ) {
    		if( $filter == '<span style="text-decoration: underline;">Infrastructure</span>' ) {
    			$long_title = 'title="<span style="text-decoration: underline;">Does the property include any of the following equipment or infrastructure? (Select all that apply) </span>"';
    		}
    		if( $filter == '<span style="text-decoration: underline;">County</span>' ) {
    			$long_title = 'title="<span style="text-decoration: underline;">Select the county your property located.</span>"';
    		}
                    if( $filter == '<span style="text-decoration: underline;">Irrigation</span>' ) {
                            $long_title = 'title="<span style="text-decoration: underline;">Which type(s) of irrigation systems does your property have? Check all that apply to your listing</span>"';                                                                                                                                           
    		}
    	}?>

    ___________________________________________________________________________________________________________________________

    Also, I’m not exactly sure I understood the final step that you provided below:

    “Finally include your?$long_title?content in the filter’s?div (I’m not sure what the “filter’s div” is)

    <div <?php echo $long_title?> class="um-search-filter um-<?php echo .....

    Are you referring to line 332? If so, my line 332 reads differently: <div class="um-search-filter um-<?php echo esc_attr( $type ) ?>-filter-type <?php echo ( $i != 0 && $i%2 !== 0 ) ? 'um-search-filter-2' : '' ?>">

    ______________________________________________________________________________________________________________________________

    I apologize for my ignorance/inexperience. I’ve been trying to figure it out myself but can’t seem to find the answers I need. Thank you SO much in advance and I’m eager to hear to hear your response.

    Thread Starter wesmed

    (@wesmed)

    @missveronicatv I just noticed that in my most recent post, the second code block converted the bold and italicized text to code. I was trying to make my edits stand out more. Anyways, below is the correct code that I would greatly appreciate feedback on:

    <?php
    	$long_title = '';
    	if ( $type == 'select' ) {
    		if( $filter == 'infrastructure' ) {
    			$long_title = 'title="Does the property include any of the following equipment or infrastructure? (Select all that apply)"';
    		}
    		if( $filter == 'county' ) {
    			$long_title = 'title="Select the county your property located."';                                                            
    		}
                    if( $filter == 'Irrigation' ) {
                            $long_title = 'title="Which type(s) of irrigation systems does your property have? Check all that apply to your listing"';                                                                    
                    }
    	}?>

    @wesmed

    Yes this code snippet looks good.

    Your meta_keys are:

    infrastructure
    county
    Irrigation

    Now insert <?php echo $long_title?>
    in the <div ... </div> where you want to see the $longtext

    <div <?php echo $long_title?> class="um-search-filter .... </div>

    will give this HTML to the browser

    <div title="my long text etc" class="um-search-filter .... </div>

    Thread Starter wesmed

    (@wesmed)

    @missveronicatv It worked! Thank you for all of your assistance.

    Thread Starter wesmed

    (@wesmed)

    @missveronicatv

    I can’t figure out how to apply my modified filter labels to my current members.php template that has the left filter box:

    https://github.com/MissVeronica/UM-Members-Directory-Left-Filter-Box

    Before, my label code was inserted after $type = UM()->member_directory()->filter_types[ $filter ]; ?> on line 330, but this doesn’t seem to be the right place to add my label code in the left filter box template. I found the $type = UM()->member_directory()->filter_types[ $filter ]; ?> on line 198 in the members.php left filter box template and tried to add my previous label code line 199, but that caused a fatal error.

    I would sincerely appreciate any help!

    @wesmed

    Before, my label code was inserted after $type = UM()->member_directory()->filter_types[ $filter ]; ?> on line 330

    Can you post this content here in the Forum.

    Thread Starter wesmed

    (@wesmed)

    @missveronicatv

    Thank you for getting back to me! I recently removed my custom filter labels from my active-theme/ultimate-member/templates/members.php because the code was no longer modifying the filter labels. I tried using my filter label code as a code snippet, but that didn’t seem to work either. The filter label code that I originally had in my members.php file is below. Do you know where this snippet should be placed in the https://github.com/MissVeronica/UM-Members-Directory-Left-Filter-Box ?

    add_filter( 'um_search_fields', function( $attrs, $field_key, $form_id ) {
    
    	if ( 'Does the property include any of the following equipment or infrastructure?' === $attrs['label'] ) {
    		$attrs['label'] = '<b>Infrastructure</b>';
    	}
    
    	if ( 'County of listed property' === $attrs['label'] ) {
    		$attrs['label'] = '<b>County</b>';
    	}
    
    	if ( 'Which property types best describe your land listing?' === $attrs['label'] ) {
    		$attrs['label'] = '<b>Property Type</b>';    
    	}
    
    	return $attrs;
    }, 10, 3 );

    Side note: the labels above show three of about a dozen that I’ve created.

    Thank you for your help!!

    missveronica

    (@missveronicatv)

    @wesmed

    The code snippet should be placed in the active theme’s functions.php file.

    Thread Starter wesmed

    (@wesmed)

    @missveronicatv

    Sorry for the delayed response. Placing the filter label code in the functions.php file resolved the issue. Thank you for all of your help!!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘How to customize text in Ultimate Member filter fields’ is closed to new replies.