user fields by role

Hi,

I'm building a tennis directory website.
I've to user roles:
-Tennis Club
-Regular Users

Tennis clubs needs to have fields such as Address, Website, telephone No., president name, etc that Regular Users don't need to have.

So I need two kind of registration for each role.

How can I solve this problem?

  • Imperative Ideas
    • HummingBird

    I think I understand what you are asking.

    You need to collect different data from clubs vs users.

    There have been several solutions for this over the last few years but the simplest would be to run a copy of the Membership plugin right here on WPMUdev. Instead of making your membership levels "Gold, Silver, Bronze" you would make them "Club, Individual" - and then use the same interface to control the pages and content they have access to.

    In terms of displaying content back out on a template level, you would just to something like this:

    <?php if (current_user_can(‘club’)) { ?>
    [html here]
    <?php } ?>

    If you don't want to use a membership plugin, let me know and I'll try to dredge up something from the old days that is still relevant. Your question has basically been answered by membership plugin systems.

  • Imperative Ideas
    • HummingBird

    Well the above code is used only when you want to display a block of HTML to a specific user role. It doesn't solve most of the issues but it can be useful when you want conditionally give a block of text or a widget registration to a specific group.

    I would start your reading here:
    http://codex.wordpress.org/Function_Reference/current_user_can

    And run some tests with text. For example:

    if ( current_user_can('moderate_comments') ) {
     echo 'The current user can moderate comments';
    }

    If you want to do this with custom roles - the guy to ask is the one who wrote the book on this stuff.

    http://wordpress.org/extend/plugins/members/

    You'll find his forum here (club access)
    http://themehybrid.com/support/forum/members

    Any time I'm struggling with a WordPress concept, Justin is the guy I go to first.

  • Imperative Ideas
    • HummingBird

    I still think what you really want is to manage everything with a Membership plugin. There are many. If the one here doesn't suit your needs, both the linked Members plugin and S2 Members have their own way of handling things.

    Use the one that works best for you.

    If you try to write all the code yourself, you'll be at it for a very long time.

  • Mason
    • DEV MAN’s Sidekick

    Hiya folks!

    @Imperative Ideas, excellent help here man. Much appreciated :slight_smile: Always love to see members chime in and help out.

    @lucop1, what you've been given already is essentially what you'll need to do. You need to create some sort of logic to separate your users (by role or by membership level for example). If you don't have any other restrictions (IE anyone can sign up for either role) then you could create 2 separate signup pages where one asks for the additional information and the other does not.

    As previously mentioned you could do this through a combination of the membership plugins, the members plugin, and possibly consider Gravity Forms to provide form integration on the front-end during signup.

    Then if you want to display that information later on in user profiles you'll have to add the info to your theme templates.

    Note that BuddyPress is one way to easily add customized profiles but there's no way by default in WordPress to have separate profiles for user role.

    Hope this helps. Let us know if you need anything further!

  • lucop1
    • New Recruit

    I'm thinking another solution:

    - make the same subscription form so a user can choose If register as a Tennis Club or Normal User

    - as soon as registration is completed an user can access to profile page.. and inside the profile page can see different informations depending on the role chosen.

    So I don't have to make two separate registration pages but two separate profile pages depending of the membership.

    Or make the same profile page but with hidden fields for a Normal Role and more field for Club.

    If I would like to use the membership plugin of wpmudev where can I modify the profile page and which code do I have to write to make this happen?

    Do you think this solution is better than the first one?

    thank you

  • Imperative Ideas
    • HummingBird

    I like how you are thinking.

    Easier, I suspect, to simply let someone decide if they are applying as a player or a club when they sign up.

    Think of it in these terms. Normally a membership registration would do something like:

    Gold: $10
    Silver: $5
    Trial: $0

    A user picks their package on registration.

    In your case, we remove the commerce component and the membership levels are:

    Player
    Club

    You get the app and approve the membership. It might make sense to ask a staff member to move the discussion to Plugins > Membership at this point so the right people are involved.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.