Skip to:
Content
Pages
Categories
Search
Top
Bottom

Age and Gender


  • nickmy
    Participant

    @nickmy

    Hello

    how can I show the age (not the birth date) after the usernamen and also the gender as an image.

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

  • nickmy
    Participant

    @nickmy

    ah and I forgot it how can I show it in the profil if a user is online?


    Roger Coathup
    Participant

    @rogercoathup

    This article shows you to calculate the age:

    http://code.hyperspatial.com/all-code/buddypress-code/buddypress-age/

    If you want to display the gender as an image, you can do it with a simple PHP if clause that checks your gender field and inserts the correct tag appropriately (or marks the field up with a class identifier), and style as a background image in your CSS.

    I suggest posting your “check for online” query as a separate forum post, so that it doesn’t get overlooked


    tubruk
    Participant

    @tubruk

    hello……whats the php code to show and image instrad of female or male in words??? thanks


    tubruk
    Participant

    @tubruk

    I found this code but it doesnt work for me:

    if ( bp_get_the_profile_field_name() == ‘Gender’ ) {
    global $field;
    $value = bp_unserialize_profile_field( $field->data->value );
    $value = explode( “, “, $value);
    if ( in_array( ‘Female’, $value ) )
    echo ‘img src=”female.gif” /’;
    if ( in_array( ‘Male’, $value ) )
    echo ‘img src=”male.gif” /’;
    }

    I’m using checkboxes and I added this in memers-loop I want also to add it to profile loop


    tubruk
    Participant

    @tubruk

    @RogerCoathup or @nickmy the age is also not working for me??? I want to show the gender and the age
    after the nickname like: NICKNAME (18 years old / *Gender as image*)


    Roger Coathup
    Participant

    @rogercoathup

    @tubruk if you are having a problem using Adam at Hyperspatial’s functions for age (they look fine to me), then please leave a comment for him on his blog

    The code you have for gender needs to be used inside a loop that’s iterating over fields, and have the correct profile fields and values set up for gender. You say you got the code from somewhere… Have you asked there about why it doesn’t work for you?

    If you don’t get an answer on gender… Start a separate thread, but post a lot more information and code showing exactly how you are trying to use the code


    tubruk
    Participant

    @tubruk

    @RogerCoathup okay thanks it works now. Now the gender is not working. It works when I use it in profile-loop.php but not in member_header just after the nick like nickname(gender/age) @nickname

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Age and Gender’ is closed to new replies.
Skip to toolbar