Changeset 4979
- Timestamp:
- 06/04/2013 04:42:44 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
includes/users/template-tags.php (modified) (1 diff)
-
templates/default/bbpress/form-user-edit.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/users/template-tags.php
r4977 r4979 110 110 * Output a sanitized user field value 111 111 * 112 * This function relies on the $filter parameter to decide how to sanitize 113 * the field value that it finds. Since it uses the WP_User object's magic 114 * __get() method, it can also be used to get user_meta values. 115 * 112 116 * @since bbPress (r2688) 113 117 * 114 118 * @param string $field Field to get 119 * @param string $filter How to filter the field value (null|raw|db|display|edit) 115 120 * @uses bbp_get_displayed_user_field() To get the field 116 121 */ 117 function bbp_displayed_user_field( $field = '' ) {118 echo bbp_get_displayed_user_field( $field );122 function bbp_displayed_user_field( $field = '', $filter = 'display' ) { 123 echo bbp_get_displayed_user_field( $field, $filter ); 119 124 } 120 125 /** 121 126 * Return a sanitized user field value 122 127 * 128 * This function relies on the $filter parameter to decide how to sanitize 129 * the field value that it finds. Since it uses the WP_User object's magic 130 * __get() method, it can also be used to get user_meta values. 131 * 123 132 * @since bbPress (r2688) 124 133 * 125 134 * @param string $field Field to get 126 * @uses sanitize_text_field() To sanitize the field 127 * @uses esc_attr() To sanitize the field 135 * @param string $filter How to filter the field value (null|raw|db|display|edit) 136 * @see WP_User::__get() for more on how the value is retrieved 137 * @see sanitize_user_field() for more on how the value is sanitized 128 138 * @uses apply_filters() Calls 'bbp_get_displayed_user_field' with the value 129 139 * @return string|bool Value of the field if it exists, else false 130 140 */ 131 function bbp_get_displayed_user_field( $field = '' ) { 132 $bbp = bbpress(); 133 $value = false; 134 135 // Return field if exists 136 if ( isset( $bbp->displayed_user->$field ) ) 137 $value = sanitize_text_field( $bbp->displayed_user->$field ); 141 function bbp_get_displayed_user_field( $field = '', $filter = 'display' ) { 142 $bbp = bbpress(); 143 144 // Juggle the user filter property because it's byref, and we don't want 145 // to muck up how other code might interact with this object. 146 $old_filter = $bbp->displayed_user->filter; 147 $bbp->displayed_user->filter = $filter; 148 149 // Get the field value from the WP_User object. We don't need to perform 150 // an isset() because the WP_User::__get() does it for us. 151 $value = $bbp->displayed_user->$field; 152 153 // Put back the user filter property that was previously juggled above. 154 $bbp->displayed_user->filter = $old_filter; 155 156 // Clean up the temporary variable 157 unset( $old_filter ); 138 158 139 159 // Return empty -
trunk/templates/default/bbpress/form-user-edit.php
r4956 r4979 23 23 <div> 24 24 <label for="first_name"><?php _e( 'First Name', 'bbpress' ) ?></label> 25 <input type="text" name="first_name" id="first_name" value="<?php bbp_displayed_user_field( 'first_name' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />25 <input type="text" name="first_name" id="first_name" value="<?php bbp_displayed_user_field( 'first_name', 'edit' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" /> 26 26 </div> 27 27 28 28 <div> 29 29 <label for="last_name"><?php _e( 'Last Name', 'bbpress' ) ?></label> 30 <input type="text" name="last_name" id="last_name" value="<?php bbp_displayed_user_field( 'last_name' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />30 <input type="text" name="last_name" id="last_name" value="<?php bbp_displayed_user_field( 'last_name', 'edit' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" /> 31 31 </div> 32 32 33 33 <div> 34 34 <label for="nickname"><?php _e( 'Nickname', 'bbpress' ); ?></label> 35 <input type="text" name="nickname" id="nickname" value="<?php bbp_displayed_user_field( 'nickname' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />35 <input type="text" name="nickname" id="nickname" value="<?php bbp_displayed_user_field( 'nickname', 'edit' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" /> 36 36 </div> 37 37 … … 56 56 <div> 57 57 <label for="url"><?php _e( 'Website', 'bbpress' ) ?></label> 58 <input type="text" name="url" id="url" value="<?php bbp_displayed_user_field( 'user_url' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" />58 <input type="text" name="url" id="url" value="<?php bbp_displayed_user_field( 'user_url', 'edit' ); ?>" class="regular-text code" tabindex="<?php bbp_tab_index(); ?>" /> 59 59 </div> 60 60 … … 81 81 <div> 82 82 <label for="description"><?php _e( 'Biographical Info', 'bbpress' ); ?></label> 83 <textarea name="description" id="description" rows="5" cols="30" tabindex="<?php bbp_tab_index(); ?>"><?php echo esc_attr( bbp_get_displayed_user_field( 'description' )); ?></textarea>83 <textarea name="description" id="description" rows="5" cols="30" tabindex="<?php bbp_tab_index(); ?>"><?php echo bbp_get_displayed_user_field( 'stuff', 'edit' ); ?></textarea> 84 84 </div> 85 85 … … 97 97 <div> 98 98 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?></label> 99 <input type="text" name="user_login" id="user_login" value="<?php bbp_displayed_user_field( 'user_login' ); ?>" disabled="disabled" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />99 <input type="text" name="user_login" id="user_login" value="<?php bbp_displayed_user_field( 'user_login', 'edit' ); ?>" disabled="disabled" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" /> 100 100 </div> 101 101 … … 103 103 <label for="email"><?php _e( 'Email', 'bbpress' ); ?></label> 104 104 105 <input type="text" name="email" id="email" value="<?php bbp_displayed_user_field( 'user_email' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />105 <input type="text" name="email" id="email" value="<?php bbp_displayed_user_field( 'user_email', 'edit' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" /> 106 106 107 107 <?php … … 109 109 // Handle address change requests 110 110 $new_email = get_option( bbp_get_displayed_user_id() . '_new_email' ); 111 if ( $new_email && $new_email != bbp_get_displayed_user_field( 'user_email' ) ) : ?>111 if ( $new_email && $new_email != bbp_get_displayed_user_field( 'user_email', 'edit' ) ) : ?> 112 112 113 113 <span class="updated inline">
Note: See TracChangeset
for help on using the changeset viewer.