Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


Option to display gender on user profile page

edited September 2010 in Questions
On signup vanilla asks a user their gender but this isn't displayed on the user profile pages by default. Is there an option somewhere on the dashboard to display it?
Tagged:

Comments

  • That's a good point!
  • edited September 2010
    That's a good answer!
  • Hmmm.. can a simple php line be inserted to the profile page?
  • I bet it gets stored in the database, so a php command that draws from that would need to be added from the profile page... eazy breezy if you know how :p
  • how to show in user profile gender? or bottom of user avatar
  • how to show in user profile gender? or bottom of user avatar

    Either would be fine.
  • LincolnLincoln Community Instigator Vanilla Staff
    FYI, it's actually used by the activity statements so it knows to use he/she in them.

    Sr Developer at Vanilla Forums [GitHub, Twitter]

  • It can be done by adding

    <?php echo T('Gender'); ?>
    <?php echo ($this->User->Gender); ?>

    to userinfo.php

    gender is stored in the database as a lower case "m" or "f" so I am guessing more code would need to be added to make it display "male" or "female". I have no idea what that would look like.
  • LincolnLincoln Community Instigator Vanilla Staff
    To accomplish that the second line could become:

    <?php echo ($this->User->Gender == 'm') ? 'Male' : 'Female'; ?>

    Sr Developer at Vanilla Forums [GitHub, Twitter]

  • To accomplish that the second line could become:

    <?php echo ($this->User->Gender == 'm') ? 'Male' : 'Female'; ?>

    Thanks Lincoln! works like a charm.
  • Lincoln said: To accomplish that the second line could become:

    <?php echo ($this->User->Gender == 'm') ? 'Male' : 'Female'; ?>

    Will something other than a ternary operator work? I want to be able to have "entities" that represent groups. I have created another "gender" which is g for group - some of the rendered sentences look VERY odd. Can't see that a switch-case would work.

  • peregrineperegrine MVP
    edited May 2012

    Of course you would have to find all the tests in all the programs and modify the gender conditional everywhere.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • peregrineperegrine MVP
    edited May 2012

    you can do anything you want for a conditional if then else, if than elseif, why wouldn't switch-case work??

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

  • edited May 2012

    I was thinking of switch-case not working in a one line statement as you have in /library/core/class.format.php.

    EG $Gender = T($Activity->ActivityGender == 'm' ? 'his' : 'her');.

    I have used:

    switch ($Activity->ActivityGender){
                        case "m":
                            $Gender = "his";
                            break;
                        case "f":
                            $Gender = "her";
                            break;
                        default:
                            $Gender = "their";
                    }
    And...

    switch ($Activity->ActivityGender){
                    case "m":
                        $Gender2 = "he";
                        break;
                    case "f":
                        $Gender2 = "she";
                        break;
                    default:
                        $Gender2 = "they";
                }

    Need to have a play around to see if it is performing as expected.

  • edited May 2012

    I want to place an associative array somewhere that can be used globally to convert m,f,t to Male,Female,Transvestite as required.

    I have done this in applications/dashboard/views/modules/userinfo.php....

    ` $GenderArray = array('m'=>'Male', 'f'=>'Female', 't'=>'Transvestite');

    <dt class="Name"><?php echo T('Gender'); ?></dt><dd><?php while(list($key,$value) = each($GenderArray)) {if ($key == $this->User->Gender) {echo $value; }} ?></dd></dt> `

    ...but don't want to place it on every page where it might be required. That would be silly. (BTW will code this a bit better later on)

    Am still getting grips with the programming approach of this system so they may be a more logical mechanism than an associative array.

    If this array is best strategy then where best to place it? Root index.php? bootstrap.php a config file?

Sign In or Register to comment.