Purely Genius Way to Add Custom Profile Fields
Everyone has been asking about how to add custom fields for profiles. I too have wanted to do some customization to the profile, but without having to modify the core or profile source. Here is what I did to make a wicked simple mp3 player for the site I’m working on.
Step 1, Create a group, and a few sub fields for that group. For this example it was “Audio Details”, then I created a sub field “favorite Band of All time” and “Favorite Album of All Time”.
Step 2. Write some code, I created a simple filter, based on a post by Andy, http://buddypress.org/forums/topic.php?id=584#post-2599 which replaced the output of the profile field with that of the mp3 widget.
Step 3. Because I didn’t want it to replace every profile field, and this is the magic, I wrote a 2nd filter, which looks at the group name, and turns on and off filtering, for different purposes. Since I didn’t want url linking filtering adding to the field value, I turned that off, and turned on my mp3 widget filter. The next time the group runs, it turns back on the default filters and removes my mp3 filters.
Step 4. Enjoy
If you have any question, feel free to ask. Also for those who may want some custom version for their own site, I’m willing to release the code as beerware.
- The topic ‘Purely Genius Way to Add Custom Profile Fields’ is closed to new replies.