Skip to:
Content
Pages
Categories
Search
Top
Bottom

change 'their' to 'his' or 'her' in activity stream

  • Avatar of sundev
    sundev
    Participant

    @sundev

    Please, I uploaded an avatar and in my activity stream; it shows sundev uploaded their profile picture 5 seconds ago. How can I change ‘their’ to ‘his’ or ‘her’? from being pluralized thanks.

Viewing 25 replies - 1 through 25 (of 25 total)
  • Avatar of Henry
    Henry
    Participant

    @henrywright-1

    How will you determine if the member is male or female?

    Avatar of sundev
    sundev
    Participant

    @sundev

    Hi Henry, Do you mean if I could includegender on registration page, the plural language thing will automatically change? If yes, any advice please?

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    Hi @sundev

    No, it wouldn’t change. You would need to filter the text accordingly depending on the gender they specify in their gender profile field.

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    Hi henrywright-1 please be more explicit a lot of us as a beginner are having the same problem. Thanks

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    Hi @mfmsw2youth,

    What is the exact text you’d like to change?

    Avatar of sundev
    sundev
    Participant

    @sundev

    Thanks for your reply, I just want the update to be shown based on their status/gender instead of using plural for all, since their’s no field for users to insert their gender on thee profile, I’m just wondering how that could be fixed, any idea?

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    @sundev you would need to capture each member’s gender using a profile field. A radio button would do it.

    Then once you have that information you could do a simple check when filtering the text.

    e.g

    
    if ( is male ) {
        // this must be a male so filter the text to say 'his'
    } else {
       // this must be a woman so filter the text to say 'her'
    }
    

    Filtering the text is the second step. If you let me know *exactly* the text you want to change, i’ll try to find where it is in the BP core code and see if a filter is available.

    Avatar of sundev
    sundev
    Participant

    @sundev

    Oh thanks a million Henry,

    Exactly, the filter will be what I need, to make it shown as your example,
    Not changing the text.

    “if ( is a male ) {
    // the filter will be ‘his’
    } else if{
    //is a female, the filter will be ‘her’
    }
    else {
    // a group, e.g company; the filter will be ‘their’
    }”

    am not really sure which of the BP file the update message that shows ‘their’ is located.
    any idea?

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    Kindly help out Henry in fixing this filter my problem is not different I have created a profile field Namely gender using radio button in buddypress xprofile members now have opportunity to select their gender male or female. Happy new year friends.

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    Hi @mfmsw2youth

    Can you paste the exact text here that you’d like to change. Eg the text that is coming up in your activity stream.

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    Example:
    “themeethurpe changed their profile picture 4 days, 12 hours ago”

    In the above line of activity “themeethurpe” is a username of a guy who changes his profile picture, but as you can see, “their” above was surpose to be a singular pronoun “his” referring to a man not two or group of people. The same thing happens either for man or woman, I just wish buddypress could differentiate a man from woman in the activities stream using profile information just like facebook and other social network site instead of using plural pronoun “THEIR” for all.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    BP is not responsible for detail such as this, it cannot be aware of aspects such as gender, as WP does not collect this info and BP just provides the user with ability to attach additional user meta via xprofile, therefore it correctly uses the only form of personal pronoun that is applicable in such circumstances where gender is undetermined, ‘Their’.

    In the third person sense that BP refers to the specific user ‘their’ is both the singular form as well as the plural, and thus the correct use.

    However if people want to change this they are free to do so although it’s not straightforward.

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    I will like to change it to HIS for male,HER for female and their for female I’m comfortable with that.As Henry explain above i think using a filter code like this will do the work only if i know how to correctly apply it in the buddypress core. Please lend your support. Thanks

    “if ( is a male ) {
    // the filter will be ‘his’
    } else if{
    //is a female, the filter will be ‘her’
    }
    else {
    // a group, e.g company; the filter will be ‘their’
    }”

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    Try adding this to your theme’s functions.php file:

    function custom_activity_text_change_avatar( $entry, $user_id ) {
        $gender = bp_get_profile_field_data( 'field=Gender&user_id=' . $user_id );
    
        if ( $gender == 'Male' ) {
            $entry = sprintf( __( '%s changed his profile picture', 'buddypress' ), $userlink );
        } else if ( $gender == 'Female' ) {
            $entry = sprintf( __( '%s changed her profile picture', 'buddypress' ), $userlink );
        } else {
            // the user hasn't told us if they are male or female so do nothing
        }
        return $entry
    }
    add_filter( 'bp_xprofile_new_avatar_action', 'custom_activity_text_change_avatar', 10, 2 );

    Notes:

    1. Your profile field should be called Gender and it should be a radio button. Options should be Male or Female

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    Oops return $entry should end with a semi colon eg

    return $entry;

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    okay Thanks Henry I will try it and get back to you.

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    @Henry
    hope it will be okay writing it like this for clearity in case of anything happen? Also do I need to put the php tag as shown below:

    <?php

    // filter gender field

    function custom_activity_text_change_avatar( $entry, $user_id ) {
    $gender = bp_get_profile_field_data( ‘field=Gender&user_id=’ . $user_id );

    if ( $gender == ‘Male’ ) {
    $entry = sprintf( __( ‘%s changed his profile picture’, ‘buddypress’ ), $userlink );
    } else if ( $gender == ‘Female’ ) {
    $entry = sprintf( __( ‘%s changed her profile picture’, ‘buddypress’ ), $userlink );
    } else {
    // the user hasn’t told us if they are male or female so do nothing
    }
    return $entry;
    }
    add_filter( ‘bp_xprofile_new_avatar_action’, ‘custom_activity_text_change_avatar’, 10, 2 );

    ?>

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    You will need the php tags only if your functions.php file doesn’t already have them.

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    You rock Henry your code works perfectly. Thank you boss

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    You’re best here boss

    Avatar of sundev
    sundev
    Participant

    @sundev

    happy new year everybody.

    Congratulations to us @mfmsw2youth. to get this solved.
    @hnla. thanks for your contribution.

    @buddypress newbies: Please ensure to put the code in your theme-child to keep the changes in the feature update.

    And of cause finally the BOSS himself :) @henrywright-1. Thank you very, very much for the great code. It worked greatly.

    Avatar of sunnyj
    sunnyj
    Participant

    @mfmsw2youth

    @Henry new bug has been found on the code.it fails to get the username
    e.g

    1.before the code we have:
    themeethurpe changed their profile picture 1 week ago

    2.after the code has been added we now have:
    changed his profile picture 2 days, 23 hours ago

    “themeethurpe” as in the above is the username which the code has omitted,however the code has successfully solved the initial problem it was intended to solve,but obviously with it inability to get the username shows that it needs to be reviewed.We appriciate your prompt contribution @Henry.

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    @mfmsw2youth Thanks for letting me know.

    I hadn’t tested the code. Please try this and let me know how you get on:

    function custom_activity_text_change_avatar( $entry, $user_id ) {
        $gender = bp_get_profile_field_data( 'field=Gender&user_id=' . $user_id );
        $userlink = bp_core_get_userlink( $user_id );
    
        if ( $gender == 'Male' ) {
            $entry = sprintf( __( '%s changed his profile picture', 'buddypress' ), $userlink );
        } else if ( $gender == 'Female' ) {
            $entry = sprintf( __( '%s changed her profile picture', 'buddypress' ), $userlink );
        } else {
            // the user hasn't told us if they are male or female so do nothing
        }
        return $entry;
    }
    add_filter( 'bp_xprofile_new_avatar_action', 'custom_activity_text_change_avatar', 10, 2 );
    Avatar of sundev
    sundev
    Participant

    @sundev

    @mfmsw2youth, you’re right, thank you for noting that.
    @henrywright-1, Thank you very much for the new code, it did the magic perfectly as Sunnyj noted.
    So far, I am satisfied and I consider it resolved. Thanks

    Avatar of Atilla Ergun Oscar
    Suzan Jasmin O.
    Participant

    @oscar582234

    Hi Henry
    that code looks great, but I dont need to change the avatar but I just want to put a little icon above avatar next to user name that reflects the user’s gender. So I came up with this idea of code, but it didnt work, could you please have a look why it doesnt work because you re expert coder maybe you can see some silly mistake I did that I cant see:

    Thanx.

    <?php
    if ( bp_get_profile_field_data( ‘field=Gender&user_id=’ . $bp->loggedin_user->id ) == ‘Man’); {
    echo ‘<i class=”icon-male”></i>’;
    }
    else {
    echo ‘<i class=”icon-female”></i>’;
    }
    ?>
Viewing 25 replies - 1 through 25 (of 25 total)

You must be logged in to reply to this topic.