Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Age and Gender (8 posts)

Started 1 year, 9 months ago by: nickmy

  • Profile picture of nickmy nickmy said 1 year, 9 months ago:

    Hello

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

  • Profile picture of nickmy nickmy said 1 year, 9 months ago:

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

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 9 months ago:

    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

  • Profile picture of tubruk tubruk said 1 year, 8 months ago:

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

  • Profile picture of tubruk tubruk said 1 year, 8 months ago:

    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

  • Profile picture of tubruk tubruk said 1 year, 8 months ago:

    @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*)

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    @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

  • Profile picture of tubruk tubruk said 1 year, 8 months ago:

    @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