Re: Adding Custom Profile Fields
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…