Add custom user profile fields in bbPress 2.4.1
-
I want to allow users to edit their address via the user profile edit page and I’ve been loosely following ardentfrost’s suggestion in this thread: http://bbpress.org/forums/topic/profile-user-specified-fields/#post-2670. My problem is that the fields are rendered on the edit page, but aren’t getting saved.
My code to add the address fields is in a file I’ve called custom-profile-fields which I’ve uploaded to the plugins page:
function get_address_keys() { return array( 'user_address_line1' => array(0, __('Address Line 1')), 'user_address_line2' => array(0, __('Address Line 2')), 'user_address_suburb' => array(0, __('Suburb')), 'user_address_state' => array(0, __('State')), 'user_address_postcode' => array(0, __('Postcode/ZIP')), 'user_address_country' => array(0, __('Country')) ); } add_filter('get_profile_info_keys', 'get_address_keys');
To display the fields I’ve inserted the following code into form-user-edit.php above the website field since it makes sense to keep the address fields in the contact info area.
<div> <label for="user_address_line1"><?php _e( 'Address Line 1', 'bbpress' ) ?></label> <input type="text" name="user_address_line1" id="user_address_line1" value="<?php bbp_displayed_user_field( 'user_address_line1', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> </div> <div> <label for="user_address_line2"><?php _e( 'Address Line 2', 'bbpress' ) ?></label> <input type="text" name="user_address_line2" id="user_address_line2" value="<?php bbp_displayed_user_field( 'user_address_line2', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> </div> <div> <label for="user_address_suburb"><?php _e( 'Suburb', 'bbpress' ) ?></label> <input type="text" name="user_address_suburb" id="user_address_suburb" value="<?php bbp_displayed_user_field( 'user_address_suburb', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> </div> <div> <label for="user_address_state"><?php _e( 'State', 'bbpress' ) ?></label> <input type="text" name="user_address_state" id="user_address_state" value="<?php bbp_displayed_user_field( 'user_address_state', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> </div> <div> <label for="user_address_postcode"><?php _e( 'Postcode/ZIP', 'bbpress' ) ?></label> <input type="text" name="user_address_postcode" id="user_address_postcode" value="<?php bbp_displayed_user_field( 'user_address_postcode', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> </div> <div> <label for="user_address_country"><?php _e( 'Country', 'bbpress' ) ?></label> <input type="text" name="user_address_country" id="user_address_country" value="<?php bbp_displayed_user_field( 'user_address_country', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> </div>
Viewing 1 replies (of 1 total)
-
Hi, have you managed to get a solution to this ? I’m in a very similar situation as you – would you like to share what you did finally ?
Thanks.
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.