Skip to:
Content
Pages
Categories
Search
Top
Bottom

Xprofile: Just show first Letter of last name

  • Avatar of Enlightenmental1
    enlightenmental1
    Participant

    @enlightenmental1

    I need a filter that will only show the first letter of the users last name

    r-1324 Trunk pulls in xprofile fields by field value and field type

    while

    RC1 pulls in xprofile by field_id field-type and field_value

    with field_id i can filter the results:

    only show if admin,

    if this, do this

    etc

    how is this possible now that trunk has changed?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    This seems to work for everything except site wide activity:

    function my_fullname_filter($name){

    $name_a = explode(\’ \’, $name);

    // if there is at least two parts to the name

    if (count($name_a) == 2){

    // replace the last part of the name with the first letter of the last part

    $name_a[count($name_a)-1] = substr($name_a[count($name_a)-1], 0, 1);

    // put it all back together

    $name = implode(\’ \’, $name_a);

    }

    return $name;

    }

    add_filter(\’bp_fetch_user_fullname\’,\’my_fullname_filter\’);

    The activity displays store the user\’s profile link in the activity table pre-generated and there is no opportunity to filter things that already exist there. You\’ll either have to wipe the activity tables or just wait till they filter out. New activity will have the filtered full name.

    Avatar of Enlightenmental1
    enlightenmental1
    Participant

    @enlightenmental1

    sweet! cool

    this goes in bp-custom.php I assume?

    Avatar of Enlightenmental1
    enlightenmental1
    Participant

    @enlightenmental1

    one more question,

    we tried this in both bp-customs.php and bp-xprofile_fielters.php…. didnt work

    we’ve changed “Full Name” to be just “First Name” and added a “Last Name” field

    I’m assuming that is why this doesnt work…..

    thanks

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    I give up.

    Avatar of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    If you’ve added a “last name” field, then just add instructions for the field to say “Only enter the first letter of your last name”. Simple as that isn’t it?

    Avatar of Enlightenmental1
    enlightenmental1
    Participant

    @enlightenmental1

    thank you for your efforts Burt,

    (im gonna keep messin with it… and post it back here once/if i get i working)

    @Andy

    I wish it was that simple…. the first and last name are required for other features on the site…. (portal site with social-network skin)

    we’ve hidden the last name altogether, but it looks empty only having first name under “general information”

    buzzwe.com

    field_1 First Name -visible

    field_2 Last Name -hidden

    field_3 Referred by -hidden / change disabled

    hidden in phpmyadmin by changing the is_public 1 to 0

    disable changes by adding filter to bp_xprofile_classes.php

    (if field_3 and on edit profile screen, hide)

    any other ideas?

    thank you

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Here is what I would do… And what I do mostly on all of my BuddyPress installations…

    In your BuddyPress->General Settings, make the “Full Name field name” be called “Display Name” or in your case “First Name/Last Initial”

    That way, people know right away what you want shown there. You won’t need to baby sit them because it says right there what you want entered. Most people will follow suit, and the ones that don’t, what’s the diff?

    (Notice I use my middle name here on bp.org?) ;)

    Then, create extra fields for First Name and Last Name, for yourself to use. Make them visible if you’d like, or whatever.

    This way you’re not trying to create a crazy filter to micro manage anything.

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    This is a custom coding issue. Not a bp issue. I’m turning off the red light on this one.

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

You must be logged in to reply to this topic.