Add an “Other” checkbox (with textbox) to a BuddyPress profile field

This is a pretty common form format:

Foo
Bar
Other

(Imagine that the textbox was next to the word ‘Other’ – wpautop() or something is being a stupid craphead and inserting a line break.)

It’s not really possible with BuddyPress’s xprofile fields. Today I dove into the codebase to see how hard it would be to add such a feature natively. The answer: Too.

So I wrote a hackish plugin instead, which you can get from this gist. (Note that it’s not in a plugin wrapper. Put it in your bp-custom.php.) To use: (1) On the Admin screen for a profile field, select ‘Yes’ under “Other Field”. (Note: it only works for checkbox fields!!) (2) ??? (3) Profit.

5 thoughts on “Add an “Other” checkbox (with textbox) to a BuddyPress profile field

  1. Daniel Schulz-Jackson

    Thanks for this. I’ve wondered about this functionality…

    Also, off the top of my head, I would have imagined that it would be most important for radio buttons, (which are exclusive as opposed to checkboxes, right?) since then if they choose “other” they definitely aren’t providing any info whatsoever.

    Am I in left field on this one?

    Reply
    1. Boone Gorges Post author

      Daniel – Makes a lot of sense. What’s written here could be modified fairly easily to support radio buttons as well (I think you’d just need to change some of the type checks, and then build the markup appropriately). If I need it for a project, I’ll build it and post it here.

      Reply
  2. Cliff DesPeaux

    Any chance this could be updated to work with current version? When I try this I get a 500 error.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *