• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP BP_XProfile_ProfileData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中BP_XProfile_ProfileData的典型用法代码示例。如果您正苦于以下问题:PHP BP_XProfile_ProfileData类的具体用法?PHP BP_XProfile_ProfileData怎么用?PHP BP_XProfile_ProfileData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BP_XProfile_ProfileData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: edit_field_options_html

 /**
  * Output the edit field options HTML for this field type.
  *
  * BuddyPress considers a field's "options" to be, for example, the items in a selectbox.
  * These are stored separately in the database, and their templating is handled separately.
  *
  * This templating is separate from {@link BP_XProfile_Field_Type::edit_field_html()} because
  * it's also used in the wp-admin screens when creating new fields, and for backwards compatibility.
  *
  * Must be used inside the {@link bp_profile_fields()} template loop.
  *
  * @param array $args Optional. The arguments passed to {@link bp_the_profile_field_options()}.
  * 
  */
 public function edit_field_options_html(array $args = array())
 {
     $original_option_values = maybe_unserialize(BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']));
     if (!empty($_POST['field_' . $this->field_obj->id])) {
         $option_values = (array) $_POST['field_' . $this->field_obj->id];
         $option_values = array_map('sanitize_text_field', $option_values);
     } else {
         $option_values = (array) $original_option_values;
     }
     //member types list as array
     $options = self::get_roles();
     $selected = '';
     //$option_values = (array) $original_option_values;
     if (empty($option_values) || in_array('none', $option_values)) {
         $selected = ' selected="selected"';
     }
     $html = '<option value="" ' . $selected . ' >----' . '</option>';
     echo $html;
     foreach ($options as $role => $label) {
         $selected = '';
         // Run the allowed option name through the before_save filter, so we'll be sure to get a match
         $allowed_options = xprofile_sanitize_data_value_before_save($role, false, false);
         // First, check to see whether the user-entered value matches
         if (in_array($allowed_options, (array) $option_values)) {
             $selected = ' selected="selected"';
         }
         echo apply_filters('bp_get_the_profile_field_options_roles', '<option' . $selected . ' value="' . esc_attr(stripslashes($role)) . '">' . $label . '</option>', $role, $this->field_obj->id, $selected);
     }
 }
开发者ID:buddydev,项目名称:bp-pseudo-role-field,代码行数:43,代码来源:class-pseudo-role-field.php


示例2: profile_screen_admin

 /**
  * profile_screen_admin()
  * 
  * Filters option for 'Teacher', only admins are allowed to access it.
  */
 function profile_screen_admin($options)
 {
     for ($i = 0; $i < count($options); $i++) {
         if (!is_super_admin() && $options[$i]->name == __('Teacher', 'bpsp') && BP_XProfile_ProfileData::get_value_byid($options[$i]->parent_id) != __('Teacher', 'bpsp')) {
             unset($options[$i]);
         }
     }
     return array_merge($options);
 }
开发者ID:warinermedia,项目名称:buddypress-courseware,代码行数:14,代码来源:roles.class.php


示例3: test_bp_has_profile_meta_cache_update_meta_cache_false

 /**
  * @group bp_xprofile_update_meta_cache
  * @group bp_has_profile
  */
 public function test_bp_has_profile_meta_cache_update_meta_cache_false()
 {
     $u = $this->factory->user->create();
     $g = $this->factory->xprofile_group->create();
     $f = $this->factory->xprofile_field->create(array('field_group_id' => $g));
     $d = new BP_XProfile_ProfileData($f, $u);
     $d->user_id = $u;
     $d->field_id = $f;
     $d->value = 'foo';
     $d->last_updated = bp_core_current_time();
     $d->save();
     bp_xprofile_add_meta($g, 'group', 'group_foo', 'group_bar');
     bp_xprofile_add_meta($f, 'field', 'field_foo', 'field_bar');
     bp_xprofile_add_meta($d->id, 'data', 'data_foo', 'data_bar');
     // prime cache
     bp_has_profile(array('user_id' => $u, 'profile_group_id' => $g, 'update_meta_cache' => false));
     $this->assertFalse(wp_cache_get($g, 'xprofile_group_meta'));
     $this->assertFalse(wp_cache_get($f, 'xprofile_field_meta'));
     $this->assertFalse(wp_cache_get($d->id, 'xprofile_data_meta'));
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:24,代码来源:cache.php


示例4: edit_field_options_html

 /**
  * Output the edit field options HTML for this field type.
  *
  * BuddyPress considers a field's "options" to be, for example, the items in a selectbox.
  * These are stored separately in the database, and their templating is handled separately.
  *
  * This templating is separate from {@link BP_XProfile_Field_Type::edit_field_html()} because
  * it's also used in the wp-admin screens when creating new fields, and for backwards compatibility.
  *
  * Must be used inside the {@link bp_profile_fields()} template loop.
  *
  * @param array $args Optional. The arguments passed to {@link bp_the_profile_field_options()}.
  * 
  */
 public function edit_field_options_html(array $args = array())
 {
     $original_option_values = maybe_unserialize(BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']));
     if (!empty($_POST['field_' . $this->field_obj->id])) {
         $option_values = (array) $_POST['field_' . $this->field_obj->id];
         $option_values = array_map('sanitize_text_field', $option_values);
     } else {
         $option_values = (array) $original_option_values;
     }
     //member types list as array
     $options = self::get_member_types();
     //$option_values = (array) $original_option_values;
     if ($this->display_as_radio()) {
         $this->_edit_options_html_radio($option_values, $options);
     } else {
         $this->_edit_options_html($option_values, $options);
     }
 }
开发者ID:buddydev,项目名称:bp-xprofile-member-type-field,代码行数:32,代码来源:class-member-type-field.php


示例5: the_invite

 function the_invite()
 {
     global $group_id;
     $this->in_the_loop = true;
     $user_id = $this->next_invite();
     $this->invite = new stdClass();
     $this->invite->user = $this->invite_data[$user_id];
     // This method previously populated the user object with
     // BP_Core_User. We manually configure BP_Core_User data for
     // backward compatibility.
     if (bp_is_active('xprofile')) {
         $this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
     }
     $this->invite->user->avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'full', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_mini = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname), 'width' => 30, 'height' => 30));
     $this->invite->user->email = $this->invite->user->user_email;
     $this->invite->user->user_url = bp_core_get_user_domain($user_id, $this->invite->user->user_nicename, $this->invite->user->user_login);
     $this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
     $this->invite->user->last_active = bp_core_get_last_activity($this->invite->user->last_activity, __('active %s', 'buddypress'));
     if (bp_is_active('groups')) {
         $total_groups = BP_Groups_Member::total_group_count($user_id);
         $this->invite->user->total_groups = sprintf(_n('%d group', '%d groups', $total_groups, 'buddypress'), $total_groups);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     $this->invite->user->total_blogs = null;
     $this->invite->group_id = $group_id;
     // Globaled in bp_group_has_invites()
     if (0 == $this->current_invite) {
         // loop has just started
         do_action('loop_start');
     }
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:38,代码来源:bp-groups-template.php


示例6: xprofile_remove_data

/**
 * When a user is deleted, we need to clean up the database and remove all the
 * profile data from each table. Also we need to clean anything up in the
 * usermeta table that this component uses.
 *
 * @package BuddyPress XProfile
 * @param int $user_id The ID of the deleted user
 */
function xprofile_remove_data($user_id)
{
    BP_XProfile_ProfileData::delete_data_for_user($user_id);
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:12,代码来源:bp-xprofile-functions.php


示例7: edit_field_options_html

 public function edit_field_options_html(array $args = array())
 {
     $options = $this->field_obj->get_children();
     $term_selected = BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']);
     $html = '';
     if ($options) {
         $taxonomy_selected = $options[0]->name;
         if (!empty($_POST['field_' . $this->field_obj->id])) {
             $new_term_selected = (int) $_POST['field_' . $this->field_obj->id];
             $term_selected = $term_selected != $new_term_selected ? $new_term_selected : $term_selected;
         }
         // Get terms of custom taxonomy selected.
         $terms = get_terms($taxonomy_selected, array('hide_empty' => false));
         if ($terms) {
             foreach ($terms as $term) {
                 $html .= sprintf('<option value="%s"%s>%s</option>', $term->term_id, $term_selected == $term->term_id ? ' selected="selected"' : '', $term->name);
             }
         }
     }
     echo apply_filters('bp_get_the_profile_field_select_custom_taxonomy', $html, $args['type'], $term_selected, $this->field_obj->id);
 }
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:21,代码来源:Bxcft_Field_Type_SelectCustomTaxonomy.php


示例8: bp_get_member_profile_data

/**
 * Get a piece of user profile data.
 *
 * When used in a bp_has_members() loop, this function will attempt
 * to fetch profile data cached in the template global. It is also safe
 * to use outside of the loop.
 *
 * @param array|string $args {
 *     Array of config parameters.
 *     @type string $field   Name of the profile field.
 *     @type int    $user_id ID of the user whose data is being fetched.
 *                           Defaults to the current member in the loop, or if not
 *                           present, to the currently displayed user.
 * }
 * @return string|bool Profile data if found, otherwise false.
 */
function bp_get_member_profile_data($args = '')
{
    global $members_template;
    if (!bp_is_active('xprofile')) {
        return false;
    }
    // Declare local variables.
    $data = false;
    // Guess at default $user_id.
    $default_user_id = 0;
    if (!empty($members_template->member->id)) {
        $default_user_id = $members_template->member->id;
    } elseif (bp_displayed_user_id()) {
        $default_user_id = bp_displayed_user_id();
    }
    $defaults = array('field' => false, 'user_id' => $default_user_id);
    $r = wp_parse_args($args, $defaults);
    // If we're in a members loop, get the data from the global.
    if (!empty($members_template->member->profile_data)) {
        $profile_data = $members_template->member->profile_data;
    }
    // Otherwise query for the data.
    if (empty($profile_data) && method_exists('BP_XProfile_ProfileData', 'get_all_for_user')) {
        $profile_data = BP_XProfile_ProfileData::get_all_for_user($r['user_id']);
    }
    // If we're in the members loop, but the profile data has not
    // been loaded into the global, cache it there for later use.
    if (!empty($members_template->member) && empty($members_template->member->profile_data)) {
        $members_template->member->profile_data = $profile_data;
    }
    // Get the data for the specific field requested.
    if (!empty($profile_data) && !empty($profile_data[$r['field']]['field_type']) && !empty($profile_data[$r['field']]['field_data'])) {
        $data = xprofile_format_profile_field($profile_data[$r['field']]['field_type'], $profile_data[$r['field']]['field_data']);
    }
    /**
     * Filters resulting piece of member profile data.
     *
     * @since 1.2.0
     *
     * @param string|bool $data Profile data if found, otherwise false.
     */
    return apply_filters('bp_get_member_profile_data', $data);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:59,代码来源:bp-members-template.php


示例9: xprofile_extract_signup_meta

function xprofile_extract_signup_meta($user_id, $meta)
{
    // Extract signup meta fields to fill out profile
    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode(',', $field_ids);
    // Loop through each bit of profile data and save it to profile.
    for ($i = 0; $i < count($field_ids); $i++) {
        if (empty($field_ids[$i])) {
            continue;
        }
        $field_value = $meta["field_{$field_ids[$i]}"];
        $field = new BP_XProfile_ProfileData();
        $field->user_id = $user_id;
        $field->value = $field_value;
        $field->field_id = $field_ids[$i];
        $field->last_updated = time();
        $field->save();
    }
    update_usermeta($user_id, 'last_activity', time());
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:20,代码来源:bp-xprofile-signup.php


示例10: get_profile_data

 /**
  * Fetch xprofile data for the current user.
  *
  * @see BP_XProfile_ProfileData::get_all_for_user() for description of
  *      return value.
  *
  * @return array See {@link BP_XProfile_Profile_Data::get_all_for_user()}.
  */
 public function get_profile_data()
 {
     return BP_XProfile_ProfileData::get_all_for_user($this->id);
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:12,代码来源:class-bp-core-user.php


示例11: delete

 function delete()
 {
     global $wpdb, $bp;
     if (!$this->id || !$this->can_delete || $this->parent_id && $this->option_order == 1) {
         return false;
     }
     if (!$wpdb->query($wpdb->prepare("DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id))) {
         return false;
     }
     /* delete the data in the DB for this field */
     BP_XProfile_ProfileData::delete_for_field($this->id);
     return true;
 }
开发者ID:hornetalcala,项目名称:trunk,代码行数:13,代码来源:bp-xprofile-classes.php


示例12: get


//.........这里部分代码省略.........
     $in_sql = '';
     if (!empty($include_field_ids)) {
         $include_field_ids_cs = implode(',', array_map('intval', $include_field_ids));
         $in_sql = " AND id IN ({$include_field_ids_cs}) ";
     }
     // Fetch the fields.
     $field_ids = $wpdb->get_col("SELECT id FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids_in} ) AND parent_id = 0 {$exclude_fields_sql} {$in_sql} ORDER BY field_order");
     // Bail if no fields.
     if (empty($field_ids)) {
         return $groups;
     }
     $field_ids = array_map('intval', $field_ids);
     // Prime the field cache.
     $uncached_field_ids = bp_get_non_cached_ids($field_ids, 'bp_xprofile_fields');
     if (!empty($uncached_field_ids)) {
         $_uncached_field_ids = implode(',', array_map('intval', $uncached_field_ids));
         $uncached_fields = $wpdb->get_results("SELECT * FROM {$bp->profile->table_name_fields} WHERE id IN ({$_uncached_field_ids})");
         foreach ($uncached_fields as $uncached_field) {
             $fid = intval($uncached_field->id);
             wp_cache_set($fid, $uncached_field, 'bp_xprofile_fields');
         }
     }
     // Pull field objects from the cache.
     $fields = array();
     foreach ($field_ids as $field_id) {
         $fields[] = xprofile_get_field($field_id);
     }
     // Store field IDs for meta cache priming.
     $object_ids['field'] = $field_ids;
     // Maybe fetch field data.
     if (!empty($r['fetch_field_data'])) {
         // Get field data for user ID.
         if (!empty($field_ids) && !empty($r['user_id'])) {
             $field_data = BP_XProfile_ProfileData::get_data_for_user($r['user_id'], $field_ids);
         }
         // Remove data-less fields, if necessary.
         if (!empty($r['hide_empty_fields']) && !empty($field_ids) && !empty($field_data)) {
             // Loop through the results and find the fields that have data.
             foreach ((array) $field_data as $data) {
                 // Empty fields may contain a serialized empty array.
                 $maybe_value = maybe_unserialize($data->value);
                 // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731.
                 if ((!empty($maybe_value) || '0' == $maybe_value) && false !== ($key = array_search($data->field_id, $field_ids))) {
                     // Fields that have data get removed from the list.
                     unset($field_ids[$key]);
                 }
             }
             // The remaining members of $field_ids are empty. Remove them.
             foreach ($fields as $field_key => $field) {
                 if (in_array($field->id, $field_ids)) {
                     unset($fields[$field_key]);
                 }
             }
             // Reset indexes.
             $fields = array_values($fields);
         }
         // Field data was found.
         if (!empty($fields) && !empty($field_data) && !is_wp_error($field_data)) {
             // Loop through fields.
             foreach ((array) $fields as $field_key => $field) {
                 // Loop through the data in each field.
                 foreach ((array) $field_data as $data) {
                     // Assign correct data value to the field.
                     if ($field->id == $data->field_id) {
                         $fields[$field_key]->data = new stdClass();
                         $fields[$field_key]->data->value = $data->value;
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:67,代码来源:class-bp-xprofile-group.php


示例13: edit_field_options_html

 public function edit_field_options_html(array $args = array())
 {
     $options = $this->field_obj->get_children();
     $checkbox_acceptance = maybe_unserialize(BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']));
     if (!empty($_POST['field_' . $this->field_obj->id])) {
         $new_checkbox_acceptance = $_POST['field_' . $this->field_obj->id];
         $checkbox_acceptance = $checkbox_acceptance != $new_checkbox_acceptance ? $new_checkbox_acceptance : $checkbox_acceptance;
     }
     $html = '<input type="checkbox" name="check_acc_' . bp_get_the_profile_field_input_name() . '" id="check_acc_' . bp_get_the_profile_field_input_name() . '"';
     if ($checkbox_acceptance == 1) {
         $html .= ' checked="checked"';
     }
     if (isset($args['required']) && $args['required']) {
         $html .= ' required="required" aria-required="true"';
     }
     $html .= ' value="1" /> ';
     $html .= '<input type="hidden" name="' . bp_get_the_profile_field_input_name() . '" id="' . bp_get_the_profile_field_input_name() . '"';
     if ($checkbox_acceptance == 1) {
         $html .= ' value="1" /> ';
     } else {
         $html .= ' value="0" /> ';
     }
     if ($options) {
         foreach ($options as $option) {
             $html .= rawurldecode($option->name);
         }
     }
     // Javascript.
     $html .= '
         <script>
             jQuery(document).ready(function() {
                 jQuery("#check_acc_' . bp_get_the_profile_field_input_name() . '").click(function() {
                     if (jQuery(this).is(":checked")) {
                         jQuery("#' . bp_get_the_profile_field_input_name() . '").val("1");
                     } else {
                         jQuery("#' . bp_get_the_profile_field_input_name() . '").val("0");
                     }
                 });
             });
         </script>
     ';
     echo apply_filters('bp_get_the_profile_field_checkbox_acceptance', $html, $args['type'], $this->field_obj->id, $checkbox_acceptance);
 }
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:43,代码来源:Bxcft_Field_Type_CheckboxAcceptance.php


示例14: edit_field_options_html

 public function edit_field_options_html(array $args = array())
 {
     $options = $this->field_obj->get_children();
     $posts_selected = maybe_unserialize(BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']));
     $html = '';
     if ($options) {
         $post_type_selected = $options[0]->name;
         if (!empty($_POST['field_' . $this->field_obj->id])) {
             $new_posts_selected = $_POST['field_' . $this->field_obj->id];
             $posts_selected = $posts_selected != $new_posts_selected ? $new_posts_selected : $posts_selected;
         }
         // Get posts of custom post type selected.
         $posts = new WP_Query(array('posts_per_page' => -1, 'post_type' => $post_type_selected, 'orderby' => 'title', 'order' => 'ASC'));
         if ($posts) {
             foreach ($posts->posts as $post) {
                 $html .= sprintf('<option value="%s"%s>%s</option>', $post->ID, !empty($posts_selected) && in_array($post->ID, $posts_selected) ? 'selected="selected"' : '', $post->post_title);
             }
         }
     }
     echo apply_filters('bp_get_the_profile_field_multiselect_custom_post_type', $html, $args['type'], $post_type_selected, $this->field_obj->id);
 }
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:21,代码来源:Bxcft_Field_Type_MultiSelectCustomPostType.php


示例15: bp_get_the_profile_field_options

	function bp_get_the_profile_field_options( $args = '' ) {
		global $field;

		$defaults = array(
			'type' => false
		);

		$r = wp_parse_args( $args, $defaults );
		extract( $r, EXTR_SKIP );

		if ( !method_exists( $field, 'get_children' ) )
			$field = new BP_XProfile_Field( $field->id );

		$options = $field->get_children();

		switch ( $field->type ) {

			case 'selectbox': case 'multiselectbox':
				if ( 'multiselectbox' != $field->type )
					$html .= '<option value="">--------</option>';

				for ( $k = 0; $k < count($options); $k++ ) {
					$option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ) );
					$option_values = (array)$option_values;

					/* Check for updated posted values, but errors preventing them from being saved first time */
					foreach( (array)$option_values as $i => $option_value ) {
						if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id] != $option_value ) {
							if ( !empty( $_POST['field_' . $field->id] ) )
								$option_values[$i] = $_POST['field_' . $field->id];
						}
					}

					if ( in_array( $options[$k]->name, (array)$option_values ) || $options[$k]->is_default_option ) {
						$selected = ' selected="selected"';
					} else {
						$selected = '';
					}

					$html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . stripslashes( esc_attr( $options[$k]->name ) ) . '">' . stripslashes( esc_attr( $options[$k]->name ) ) . '</option>', $options[$k] );
				}
				break;

			case 'radio':
				$html = '<div id="field_' . $field->id . '">';

				for ( $k = 0; $k < count($options); $k++ ) {
					$option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id);

					/* Check for updated posted values, but errors preventing them from being saved first time */
					if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) {
						if ( !empty( $_POST['field_' . $field->id] ) )
							$option_value = $_POST['field_' . $field->id];
					}

					if ( $option_value == $options[$k]->name || $value == $options[$k]->name || ( empty( $option_value ) && $options[$k]->is_default_option ) ) {
						$selected = ' checked="checked"';
					} else {
						$selected = '';
					}

					$html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . stripslashes( esc_attr( $options[$k]->name ) ) . '"> ' . stripslashes( esc_attr( $options[$k]->name ) ) . '</label>', $options[$k] );
				}

				$html .= '</div>';
				break;

			case 'checkbox':
				$option_values = BP_XProfile_ProfileData::get_value_byid($options[0]->parent_id);

				/* Check for updated posted values, but errors preventing them from being saved first time */
				if ( isset( $_POST['field_' . $field->id] ) && $option_values != maybe_serialize( $_POST['field_' . $field->id] ) ) {
					if ( !empty( $_POST['field_' . $field->id] ) )
						$option_values = $_POST['field_' . $field->id];
				}

				$option_values = maybe_unserialize($option_values);

				for ( $k = 0; $k < count($options); $k++ ) {
					for ( $j = 0; $j < count($option_values); $j++ ) {
						if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) || $options[$k]->is_default_option ) {
							$selected = ' checked="checked"';
							break;
						}
					}

					$html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', '<label><input' . $selected . ' type="checkbox" name="field_' . $field->id . '[]" id="field_' . $options[$k]->id . '_' . $k . '" value="' . stripslashes( esc_attr( $options[$k]->name ) ) . '"> ' . stripslashes( esc_attr( $options[$k]->name ) ) . '</label>', $options[$k] );
					$selected = '';
				}
				break;

			case 'datebox':

				if ( !empty( $field->data->value ) ) {
					$day = date("j", $field->data->value);
					$month = date("F", $field->data->value);
					$year = date("Y", $field->data->value);
					$default_select = ' selected="selected"';
				}

//.........这里部分代码省略.........
开发者ID:n-sane,项目名称:zaroka,代码行数:101,代码来源:bp-xprofile-templatetags.php


示例16: bp_get_member_profile_data

function bp_get_member_profile_data($args = '')
{
    global $bp, $members_template;
    if (!bp_is_active('xprofile')) {
        return false;
    }
    // Declare local variables
    $data = false;
    $user_id = 0;
    // Guess at default $user_id
    if (!empty($members_template->member->id)) {
        $user_id = $members_template->member->id;
    } elseif (!empty($bp->displayed_user->id)) {
        $user_id = $bp->displayed_user->id;
    }
    $defaults = array('field' => false, 'user_id' => $user_id);
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Populate the user if it hasn't been already.
    if (empty($members_template->member->profile_data) && method_exists('BP_XProfile_ProfileData', 'get_all_for_user')) {
        $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
    }
    // Get the field data if there is data to get
    if (!empty($members_template->member->profile_data)) {
        $data = xprofile_format_profile_field($members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data']);
    }
    return apply_filters('bp_get_member_profile_data', $data);
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:28,代码来源:bp-members-template.php


示例17: edit_field_options_html

 /**
  * Output the edit field options HTML for this field type.
  *
  * BuddyPress considers a field's "options" to be, for example, the items in a selectbox.
  * These are stored separately in the database, and their templating is handled separately.
  *
  * This templating is separate from {@link BP_XProfile_Field_Type::edit_field_html()} because
  * it's also used in the wp-admin screens when creating new fields, and for backwards compatibility.
  *
  * Must be used inside the {@link bp_profile_fields()} template loop.
  *
  * @param array $args Optional. The arguments passed to {@link bp_the_profile_field_options()}.
  * @since 2.0.0
  */
 public function edit_field_options_html(array $args = array())
 {
     $option_value = BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']);
     $options = $this->field_obj->get_children();
     $html = sprintf('<div id="%s">', esc_attr('field_' . $this->field_obj->id));
     for ($k = 0, $count = count($options); $k < $count; ++$k) {
         // Check for updated posted values, but errors preventing them from
         // being saved first time
         if (isset($_POST['field_' . $this->field_obj->id]) && $option_value != $_POST['field_' . $this->field_obj->id]) {
             if (!empty($_POST['field_' . $this->field_obj->id])) {
                 $option_value = sanitize_text_field($_POST['field_' . $this->field_obj->id]);
             }
         }
         // Run the allowed option name through the before_save filter, so
         // we'll be sure to get a match
         $allowed_options = xprofile_sanitize_data_value_before_save($options[$k]->name, false, false);
         $selected = '';
         if ($option_value === $allowed_options || empty($option_value) && !empty($options[$k]->is_default_option)) {
             $selected = ' checked="checked"';
         }
         $new_html = sprintf('<label><input %1$s type="radio" name="%2$s" id="%3$s" value="%4$s">%5$s</label>', $selected, esc_attr("field_{$this->field_obj->id}"), esc_attr("option_{$options[$k]->id}"), esc_attr(stripslashes($options[$k]->name)), esc_html(stripslashes($options[$k]->name)));
         /**
          * Filters the HTML output for an individual field options radio button.
          *
          * @since 1.1.0
          *
          * @param string $new_html Label and radio input field.
          * @param object $value    Current option being rendered for.
          * @param int    $id       ID of the field object being rendered.
          * @param string $selected Current selected value.
          * @param string $k        Current index in the foreach loop.
          */
         $html .= apply_filters('bp_get_the_profile_field_options_radio', $new_html, $options[$k], $this->field_obj->id, $selected, $k);
     }
     echo $html . '</div>';
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:50,代码来源:class-bp-xprofile-field-type-radiobutton.php


示例18: test_get_all_for_user_cached

 /**
  * @group get_all_for_user
  */
 public function test_get_all_for_user_cached()
 {
     $u = $this->factory->user->create();
     $g1 = $this->factory->xprofile_group->create();
     $g2 = $this->factory->xprofile_group->create();
     $f1 = $this->factory->xprofile_field->create(array('type' => 'textbox', 'field_group_id' => $g1));
     $f2 = $this->factory->xprofile_field->create(array('type' => 'radio', 'field_group_id' => $g2));
     $time = bp_core_current_time();
     $g0 = new BP_XProfile_Group(1);
     $f0 = new BP_XProfile_Field(1);
     $d0 = new BP_XProfile_ProfileData(1, $u);
     $d1 = new stdClass();
     $d1->user_id = $u;
     $d1->field_id = $f1;
     $d1->value = 'foo';
     $d1->last_updated = $time;
     $d1->id = 1;
     $d2 = new stdClass();
     $d2->user_id = $u;
     $d2->field_id = $f2;
     $d2->value = 'bar';
     $d2->last_updated = $time;
     $d2->id = 2;
     wp_cache_set("{$u}:{$f1}", $d1, 'bp_xprofile_data');
     wp_cache_set("{$u}:{$f2}", $d2, 'bp_xprofile_data');
     $u_obj = new WP_User($u);
     $g1_obj = new BP_XProfile_Group($g1);
     $g2_obj = new BP_XProfile_Group($g2);
     $f1_obj = new BP_XProfile_Field($f1);
     $f2_obj = new BP_XProfile_Field($f2);
     $expected = array('user_login' => $u_obj->user_login, 'user_nicename' => $u_obj->user_nicename, 'user_email' => $u_obj->user_email, $f0->name => array('field_group_id' => $g0->id, 'field_group_name' => $g0->name, 'field_id' => $f0->id, 'field_type' => $f0->type, 'field_data' => $d0->value), $f1_obj->name => array('field_group_id' => $g1, 'field_group_name' => $g1_obj->name, 'field_id' => $f1, 'field_type' => $f1_obj->type, 'field_data' => $d1->value), $f2_obj->name => array('field_group_id' => $g2, 'field_group_name' => $g2_obj->name, 'field_id' => $f2, 'field_type' => $f2_obj->type, 'field_data' => $d2->value));
     $this->assertEquals($expected, BP_XProfile_ProfileData::get_all_for_user($u));
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:36,代码来源:class-bp-xprofile-profiledata.php


示例19: edit_field_options_html

 /**
  * Output the edit field options HTML for this field type.
  *
  * BuddyPress considers a field's "options" to be, for example, the items in a selectbox.
  * These are stored separately in the database, and their templating is handled separately.
  *
  * This templating is separate from {@link BP_XProfile_Field_Type::edit_field_html()} because
  * it's also used in the wp-admin screens when creating new fields, and for backwards compatibility.
  *
  * Must be used inside the {@link bp_profile_fields()} template loop.
  *
  * @since 2.0.0
  *
  * @param array $args Optional. The arguments passed to {@link bp_the_profile_field_options()}.
  */
 public function edit_field_options_html(array $args = array())
 {
     $date = BP_XProfile_ProfileData::get_value_byid($this->field_obj->id, $args['user_id']);
     $day = 0;
     $month = 0;
     $year = 0;
     $html = '';
     $eng_months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     // Set day, month, year defaults.
     if (!empty($date)) {
         // If Unix timestamp.
         if (is_numeric($date)) {
             $day = date('j', $date);
             $month = date('F', $date);
             $year = date('Y', $date);
             // If MySQL timestamp.
         } else {
             $day = mysql2date('j', $date);
             $month = mysql2date('F', $date, false);
             // Not localized, so that selected() works below.
             $year = mysql2date('Y', $date);
         }
     }
     // Check for updated posted values, and errors preventing them from
     // being saved first time.
     if (!empty($_POST['field_' . $this->field_obj->id . '_day'])) {
         $new_day = (int) $_POST['field_' . $this->field_obj->id . '_day'];
         $day = $day != $new_day ? $new_day : $day;
     }
     if (!empty($_POST['field_' . $this->field_obj->id . '_month'])) {
         if (in_array($_POST['field_' . $this->field_obj->id . '_month'], $eng_months)) {
             $new_month = $_POST['field_' . $this->field_obj->id . '_month'];
         } else {
             $new_month = $month;
         }
         $month = $month !== $new_month ? $new_month : $month;
     }
     if (!empty($_POST['field_' . $this->field_obj->id . '_year'])) {
         $new_year = (int) $_POST['field_' . $this->field_obj->id . '_year'];
         $year = $year != $new_year ? $new_year : $year;
     }
     // $type will be passed by calling function when needed.
     switch ($args['type']) {
         case 'day':
             $html = sprintf('<option value="" %1$s>%2$s</option>', selected($day, 0, false), __('----', 'buddypress'));
             for ($i = 1; $i < 32; ++$i) {
                 $html .= sprintf('<option value="%1$s" %2$s>%3$s</option>', (int) $i, selected($day, $i, false), (int) $i);
             }
             break;
         case 'month':
             $months = array(__('January', 'buddypress'), __('February', 'buddypress'), __('March', 'buddypress'), __('April', 'buddypress'), __('May', 'buddypress'), __('June', 'buddypress'), __('July', 'buddypress'), __('August', 'buddypress'), __('September', 'buddypress'), __('October', 'buddypress'), __('November', 'buddypress'), __('December', 'buddypress'));
             $html = sprintf('<option value="" %1$s>%2$s</option>', selected($month, 0, false), __('----', 'buddypress'));
             for ($i = 0; $i < 12; ++$i) {
                 $html .= sprintf('<option value="%1$s" %2$s>%3$s</option>', esc_attr($eng_months[$i]), selected($month, $eng_months[$i], false), $months[$i]);
             }
             break;
         case 'year':
             $html = sprintf('<option value="" %1$s>%2$s</option>', selected($year, 0, false), __('----', 'buddypress'));
             for ($i = 2037; $i > 1901; $i--) {
                 $html .= sprintf('<option value="%1$s" %2$s>%3$s</option>', (int) $i, selected($year, $i, false), (int) $i);
             }
             break;
     }
     /**
      * Filters the output for the profile field datebox.
      *
      * @since 1.1.0
      *
      * @param string $html  HTML output for the field.
      * @param string $value Which date type is being rendered for.
      * @param string $day   Date formatted for the current day.
      * @param string $month Date formatted for the current month.
      * @param string $year  Date formatted for the current year.
      * @param int    $id    ID of the field object being rendered.
      * @param string $date  Current date.
      */
     echo apply_filters('bp_get_the_profile_field_datebox', $html, $args['type'], $day, $month, $year, $this->field_obj->id, $date);
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:93,代码来源:class-bp-xprofile-field-type-datebox.php


示例20: get_edit_html

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP BYT_Theme_Utils类代码示例发布时间:2022-05-23
下一篇:
PHP BP_XProfile_Field类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap