Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding Custom Profile Fields


  • M
    Member

    @box87

    I’m trying to add custom fields to my bbPress profile page, like deviantArt username, real name, etc. How would I go about doing this?

    I was checking out some WordPress custom meta plugins, but they weren’t really cutting it.

    I’m running bbPress alongside WordPress, and I’ve got the integration running just fine.

    My guess is that there’s an easy way of doing this. I was picking through the bbPress functions, and there’s all kinds of good stuff available.

    Thank you in advance… I must run, I have class to get to.

Viewing 12 replies - 1 through 12 (of 12 total)
  • If you go to bb-includes/functions.php you’ll see a function called “get_profile_info_keys()”

    This function holds the data you want, but you don’t want to adjust that file directly since it’s a core file, however, in the current release of my avatar plug-in, you do have to change that line.

    But if you notice, it says return apply_filters( 'get_profile_info_keys', yadda yadda );

    Anywhere it says “apply_filters” you can make your own.

    So I haven’t done this myself yet, though now that I look closer at it, I think I’m going to rerelease my avatar plugin with this change.

    Make a plug-in file in your my-plugins directory and put this in it:

    add_filter( 'get_profile_info_keys', array('user_email' => array(1, __('Email')), 'user_url' => array(0, __('Website')), 'from' => array(0, __('Location')), 'occ' => array(0, __('Occupation')), etc....

    And just keep adding stuff til you have everything you want. the ‘1’ in the “Email” part means that it’s required during registration. Everything else is 0’s because they are not required fields… you can, of course, change this.


    M
    Member

    @box87

    Awesome, I’ll give it a go.

    Funny you mention your avatar plugin… I saw yours but I wasn’t crazy about the modification of core files, so I wrote my own upload script. It uploads a JPG, GIF, or PNG file under 20kb, with a fixed resolution of 64×64 px. If any of these conditions aren’t met, it spits out an error.

    If your username is UserName, then the file is named username-avatar.gif or whatever image extension is.

    I have a simple detection script for the image in the file post.php. It works for now, but I’d like something a little better. If you’d like a peek at the code just let me know.

    I’m working on a PM system, and a post preview “plugin”… it’s slow going though, as college gets in the way quite a considerable bit.

    Thanks,

    Mike

    lol, I’m actually working on a PM system as well :) Post Preview is on my to-do list.

    You can actually view what I have done, am doing, and plan to do on my forums. http://www.rayd.org/forums/

    Right now I’m putting some finishing touches down on a memberlist plugin with a really cool admin feature I think everyone will enjoy.

    As for my avatar plugin, I’d love to incorporate what you’ve done to make it more powerful, or maybe we can make your’s pluggable and we can make them work together to make one good plugin :)

    Your site is down :(

    Mine is? Try again, you might have seen it when I was fiddling with something and it errored out.


    M
    Member

    @box87

    Hey there, I’m trying something out here… I made a plugin called template-functions.php and I’m trying out one thing here.

    If I put this line:

    add_filter(

    'get_profile_info_keys',

    'extra_profile_info'

    );

    function extra_profile_info () {}

    my profile info is gone, except for the username field and a password field.

    I can only see the password field if I view the source… It’s not visible…

    Still working on it…

    edit: Oh boy, I guess the function extra_profile_info exists! Still going…

    another edit:

    Well now check this out:

    https://trac.bbpress.org/changeset/327

    10/13/05… “Hooks for extra fields”?

    This is more like it!


    M
    Member

    @box87

    I think I’ve found a solution, by searching the forums (go figure).

    https://bbpress.org/forums/topic/313?replies=21#post-1672

    I quite like this plugin… I’m going to enable it on my forums.

    I should have realized… I’m adding an action, not a filter…

    [edit] OK, well I’m one step closer, kind of. I need to make a new row (?) for each new profile field.

    [another edit]

    I’m closer: here’s the function I need; bb_update_usermeta


    M
    Member

    @box87

    Alrighty, here’s the scoop:

    I added <?php do_action('extra_profile_info_display', $user); ?> to my profile.php file, right above the second to last line, <?php profile_pages(); ?>.

    In my template-functions.php file, I have the following:

    function extra_profile_edit() {

    //Globals

    global $user_id, $bb_current_user,$bbdb;

    // Get dA username, if it exists

    $da_username = $bbdb->get_var("SELECT meta_value FROM $bbdb->usermeta WHERE meta_key = 'da_username' AND user_id = '$user_id'");

    // Get the user's real name, if it exists

    $user_realname = $bbdb->get_var("SELECT meta_value FROM $bbdb->usermeta WHERE meta_key = 'user_realname' AND user_id = '$user_id'");

    // Input fields that have a default value of the set variable

    echo "

    <input

    name="da_username"

    id="da_username"

    type="field"

    value="$da_username" />

    .deviantart.com

    <input name="user_realname"

    id="user_realname"

    type="field"

    value="$user_realname"

    />";

    }

    And now for the real meat of the thing:

    function extra_update() {

    global $user_id;

    bb_update_usermeta($user_id, "da_username", $_POST['da_username']);

    bb_update_usermeta($user_id, "user_realname", $_POST['user_realname']);

    }

    add_action('extra_profile_info', 'extra_profile_edit');

    add_action('profile_edited', 'extra_update');

    add_action('extra_profile_info_display', 'extra_display');

    My apologies for the length of the post…

    I have read this thread but it is not clear if there is a well established procedure to add custom fields to the user profile. I hope to sort it out but in the meantime maybe someone out there can add an ordered and well documented step by step procedure.

    Encouragements and many thanks!

    After spending some days I found a clear well laid out solution here: https://bbpress.org/forums/topic/profile-user-specified-fields#post-2670

    Using ardentfrost’s method to add custom fields for users. It’s working perfectly. What can I put in my post.php file in order to pull the info from those custom fields on post pages (i.e., beneath the posters user name and member status I’d like to display info from the custom fields)? Thanks so much. (I realize that no one’s replied to this thread for over a year, but I thought I’d give it a try.)


    college beauty
    Member

    @college-beauty

    Would this work for changing a current field?

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