When you create profile fields in BuddyPress, they apply to every user in the same way. Each user responds to the same set of questions, but this could stand to be a little more flexible to account for differences in users. What if you could conditionally show profile fields, based on a user’s answers to certain questions?
Prolific BuddyPress plugin developer Brajesh Singh created a plugin to do exactly this. Conditional Profile Fields for BuddyPress gives site administrators the ability to set conditions for hiding/showing profile fields based on a user’s responses to other profile fields. For example, let’s say you create a field to ask if the user is a morning or night person.
You can then set up a second question, such as “Do you eat breakfast?” With the help of this plugin, you can make the question contingent on the first question where you asked if the person is a morning or night person. Perhaps you are curious if a user who identifies as a “night person” also eats breakfast. While editing the breakfast question, scroll to the bottom and you will find a new box for setting a Visibility Condition.
From the dropdown, select the question you want as the condition, show/hide, and the value that field is contingent upon. The plugin also includes support for muti-option fields.
Once you have your condition set, you can navigate to the frontend to see that the conditional fields are shown or hidden based on your selection. Here’s a quick demo:
If you mark the first profile field as “Required” when creating it, then BuddyPress will also show the field on the registration form and conditional fields will also apply. The plugin currently supports the following features:
- Compatible with 99% of WordPress themes
- 2 visibility options to either show the field or hide the field based on the condition
- A field dropdown box to allow you to select the field that governs the display of this field
- 6 operators to match the values (6 operators for the number/text/textarea field and 2 operators for matching the multi-select box/check box/radio)
- It supports the multi-type field as well as other fields (and should support custom profile fields automatically)
- Currently the date field is not supported for creating conditions
The Conditional Profile Fields plugin is an excellent addition to any BuddyPress site that brings together different types of users. For example, educational sites might include students, teachers, tutors, etc. Instead of using a complicated plugin to set up different user types, you can add a conditional profile field to ask the user to select from student, teacher, etc. From there you can create different profile field groups containing questions conditional upon the user’s previous selection.
Conditional profile fields could also be useful for many other types of social networks, including:
- Dating sites
- Professional organizations
- Sports teams
- Multilingual communities
- Job or freelancer networks
- Hobby or interest-based networks
I tested the plugin with BuddyPress 2.1 beta 1 and found that it works exactly as advertised. Conditional profile fields are an excellent way to extend a niche social network to display profile fields specifically tailored to different user types. Download Conditional Profile Fields for BuddyPress for free from BuddyDev.com.