Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can I add form fields to the registration page?

  • Title says it all – I’d like to add a couple of extra fields to the registration form, like an ID number and make them mandatory too. Is this possible?

    Cheers

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

  • kevinjohngallagher
    Member

    @kevinjohngallagher

    Not really. At least not easily, and there is no existing and easy to use plugin. That said, if you’re dilligent enough and have enough PHP skills you could probably garnish a solution from the threads _ck_ links to here:

    Extra dropdown field in registration page

    [EDIT chrishajer]

    If you have bbPress integrated with WordPress (sharing database and logins), then I strongly suggest using WordPress for registrations as you can theme and plugin to your hearts content there.


    Ben L.
    Member

    @nightgunner5

    <?php
    /*
    Plugin Name: My Profile Keys
    */

    function my_profile_keys( $a ) {
    $a['my_key_id'] = array(
    true, // Required
    'ID number', // Label
    'text', // Type
    '', // Value
    '' // Default when not set
    );
    return $a;
    }

    add_filter( 'get_profile_keys', 'my_profile_keys' );

    Untested, but should work. (Change the lt thing to a less than sign – the bbPress.org forums have some kind of glitch).


    chrishajer
    Participant

    @chrishajer

    pagal, I deleted your response to kevinjohngallagher.


    pagal
    Participant

    @pagal

    @chrishajer its not real a democracy…If you deleted my whole topic then you should also delete the whole topic of kevinjohngallagher which was against to me you just edit the kevin’s topic not delete it. You can also edit my topic but you did not. And I did not just give response to kevin, I also said something to zeal… can you please tell me why you delete the topic’s portion which was for zeal?

    Thanks :-)


    chrishajer
    Participant

    @chrishajer

    pagal, please feel free to email me at chrishajer at gmail – com. I deleted Kevin’s comment about you because it was unwarranted and off-topic, and therefore your whole response became unnecessary and was deleted.

    I deleted your whole comment because the information for zaerl is also off-topic here and hijacked the topic.

    I don’t wish to derail this topic any further. Feel free to email me.

    Thanks for your help on this guys, and apologies for not searching the forum more thoroughly for similar topics already started!

    I’m not ignoring your advice, but just trying to make things work within my limited knowledge. What I’ve done is opened up the register.php file and commented out the following lines:

    unset($profile_info_keys['first_name']);
    unset($profile_info_keys['last_name']);

    …which has had the effect of making them appear on the register form. This is good for me because we need people to enter their full names to use the forum (requirement from client)

    Also, I’ve edited the functions.bb-core.php file and changed:

    'from' => array(0, __('Location')),

    …to read:

    'from' => array(1, __('ID Ref')),

    …which is pretty crude but makes it mandatory and changes the label to what I require. The obvious downside is that if any existing members have specified a location, it will appear with this new label.

    This is the quick n dirty solution, but I just want to check it’s not going to kill anything. Thanks


    kevinjohngallagher
    Member

    @kevinjohngallagher

    Great to hear you’ve got something working, and thanks for reporting back!


    mr_pelle
    Participant

    @mr_pelle

    Here’s a more complete non-core-hacking solution:

    <?php
    /*
    Plugin Name: Customize User Profile
    */

    add_filter( 'get_profile_info_keys', 'customize_user_profile', 10, 2 );

    function customize_user_profile( $fields, $context ) {
    /**
    * Remove undesired fields
    *
    * Commented = left
    * Uncommented = removed
    */
    // unset( $fields['first_name'] );
    // unset( $fields['last_name'] );
    unset( $fields['user_url'] );
    // unset( $fields['from'] );
    unset( $fields['occ'] );
    unset( $fields['interest'] );

    /**
    * Add new fields
    *
    * Quoting functions.bb-core.php, line 906:
    * meta_key => (required?, Label, hCard property). Don't use user_{anything} as the name of your meta_key.
    */
    $fields['my_meta_key'] = array(
    false,
    __( 'My meta key' ),
    'text'
    );

    return $fields;
    }
    ?>

    Of course, as usual, replace < and > with angular parentheses.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar