Can we force the full name profile field to Capitalize?

Hi -

Attaching screen shots of CSS associated with the full name field - is this enough information to help me right either CSS or a function to force the first-character capitalization of words in the BuddyPress Full Name field? Not "all caps," but rather change "jane doe" to "Jane Doe" when the user neglects to capitalize her name.

Thank you for any help or insight!

James

  • Michael Bissett

    Hey @James Wolfensberger, hope you're doing well this evening! :slight_smile:

    This can be done with a bit of CSS code, the "text-transform" property is what you'd be looking for here. I'm not seeing the selector for the cell that contains the name, but this should do the trick:

    .field_full-name > td:nth-of-type(2) {
    text-transform: capitalize;
    }

    Hope this helps! :slight_smile:

    Kind Regards,
    Michael

  • James Wolfensberger

    Michael, I think I might have taken us down the wrong path. Did I mistakenly think that this could correct all instances of a member's full name to become capitalized?

    This particular CSS did not modify the presentation of the Full Name on the profile; and am I now correct that even if it did, that it would not change the name in other places within the BuddyPress site?

    I'm sorry if I had the wrong idea here. Maybe you can let me know a measure we can take to "force" all full names to capitalized?

    James

  • Adam Czajczyk

    Hello James,

    I hope you're well today!

    If you wish to capitalize each and every full name, regardless of when and were it appears, you'll have to use PHP instead of CSS. That being said, could you please place this code in your BP theme's functions.php file?

    apply_filters( 'bp_displayed_user_fullname', isset( $bp->displayed_user->fullname ) ? ucwords($bp->displayed_user->fullname) : '' )

    Give it a try and let me know if it worked as desired, please.

    Cheers,
    Adam

  • Adam Czajczyk

    Hello James,

    I hope you're well today and I apologize for keeping you waiting!

    It seems like not everything described in BP docs works as expected :slight_smile: That's why it took me some time to find a solution but I believe I finally managed to produce a working fix. That said, place this code in your theme's functions.php file:

    function wpmu_capitalize_bp_member_name() {
    global $members_template;
    return ucfirst($members_template->member->fullname);
    }

    add_filter('bp_member_name','wpmu_capitalize_bp_member_name');

    function wpmu_capitalize_bp_displayed_user_fullname() {
    	global $members_template,$bp;
    	//return ucfirst($members_template->member->fullname);
    	if (isset( $bp->displayed_user->fullname )):
    		return ucfirst($bp->displayed_user->fullname);
    	else:
    		return ' ';
    	endif;
    }
    add_filter('bp_displayed_user_fullname','wpmu_capitalize_bp_displayed_user_fullname');

    This is tested in my sandbox WP install and it seems to do the trick as expected.

    Please let me know if it worked for you.

    Cheers,
    Adam

  • James Wolfensberger

    Hello Adam! Thanks for your interest in this issue.

    There were two sections of code in your last response. One is within the normal text and one is within a code block. I wasn't sure which one to try, or if they both work together somehow; so I tried each of the three possible scenarios.

    The section of code displayed in the code block in your last post did render the first name as capitalized, but only on the profile and the "What's new" prompt, and the last name is not capitalized. Otherwise, the results are shown in the attachments. If this issue is overly complex for here, I do understand. But if you have any more insight, I appreciate your help!

    James

  • Michael Bissett

    Hey @James Wolfensberger,

    Try combining the code snippet that my colleague @Adam Czajczyk provided here with this CSS code (I tested it out on your testing site, and it works):

    #members-list .item-title a {
        text-transform: capitalize;
    }
    
    .bbp-user-page h1.entry-title {
        text-transform: capitalize;
    }
    
    .field_full-name .data p {
        text-transform: capitalize;
    }
    
    .activity_update .activity-header > a:nth-of-type(1) {
    text-transform: capitalize;
    }
    
    #member-list #item-content.groups a {
    text-transform: capitalize;
    }
    
    div#invite-list li {
    text-transform: capitalize;
    }

    Let me know if this helps please! :slight_smile:

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.