当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_XProfile_Field::set_member_types方法代码示例

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


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

示例1: test_passing_empty_member_type_to_get_fields_for_member_type_should_return_unrestricted_fields

 public function test_passing_empty_member_type_to_get_fields_for_member_type_should_return_unrestricted_fields()
 {
     $f2 = $this->factory->xprofile_field->create(array('field_group_id' => $this->field_group_id));
     $field_2 = new BP_XProfile_Field($f2);
     $field_2->set_member_types(array('foo'));
     $found = BP_XProfile_Field::get_fields_for_member_type('');
     $this->assertEqualSets(array(1, $this->field_id), array_keys($found));
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:8,代码来源:member_types.php

示例2: test_member_type_null_should_be_respected

 /**
  * @group member_types
  * @ticket BP5192
  */
 public function test_member_type_null_should_be_respected()
 {
     $g = $this->factory->xprofile_group->create();
     $f1 = $this->factory->xprofile_field->create(array('field_group_id' => $g));
     $f2 = $this->factory->xprofile_field->create(array('field_group_id' => $g));
     bp_register_member_type('foo');
     bp_register_member_type('bar');
     $field1 = new BP_XProfile_Field($f1);
     $field1->set_member_types(array('foo'));
     $found_groups = BP_XProfile_Group::get(array('member_type' => array('null'), 'fetch_fields' => true));
     // The groups aren't indexed, so we have to go looking for it.
     foreach ($found_groups as $fg) {
         if ($g == $fg->id) {
             $the_group = $fg;
         }
     }
     $this->assertNotContains($f1, wp_list_pluck($the_group->fields, 'id'));
     $this->assertContains($f2, wp_list_pluck($the_group->fields, 'id'));
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:23,代码来源:class-bp-xprofile-group.php

示例3: xprofile_admin_manage_field

/**
 * Handles the adding or editing of profile field data for a user.
 */
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $wpdb, $message, $groups;
    $bp = buddypress();
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->is_required = $_POST['required'];
            $field->type = $_POST['fieldtype'];
            $field->name = $_POST['title'];
            if (!empty($_POST['description'])) {
                $field->description = $_POST['description'];
            } else {
                $field->description = '';
            }
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = $_POST["sort_order_{$field->type}"];
            }
            $field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (empty($field->field_order) || is_wp_error($field->field_order)) {
                $field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            // For new profile fields, set the $field_id. For existing profile
            // fields, this will overwrite $field_id with the same value.
            $field_id = $field->save();
            if (empty($field_id)) {
                $message = __('There was an error saving the field. Please try again.', 'buddypress');
                $type = 'error';
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                // @todo remove these old options
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                // Set member types.
                if (isset($_POST['has-member-types'])) {
                    $member_types = array();
                    if (isset($_POST['member-types'])) {
                        $member_types = stripslashes_deep($_POST['member-types']);
                    }
                    $field->set_member_types($member_types);
                }
                // Validate default visibility
                if (!empty($_POST['default-visibility']) && in_array($_POST['default-visibility'], wp_list_pluck(bp_xprofile_get_visibility_levels(), 'id'))) {
                    bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
                }
                // Validate custom visibility
                if (!empty($_POST['allow-custom-visibility']) && in_array($_POST['allow-custom-visibility'], array('allowed', 'disabled'))) {
                    bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
                }
                // Validate signup
                if (!empty($_POST['signup-position'])) {
                    bp_xprofile_update_field_meta($field_id, 'signup_position', (int) $_POST['signup-position']);
                } else {
                    bp_xprofile_delete_meta($field_id, 'field', 'signup_position');
                }
                /**
                 * Fires at the end of the process to save a field for a user, if successful.
                 *
                 * @since BuddyPress (1.0.0)
                 *
                 * @param BP_XProfile_Field $field Current BP_XProfile_Field object.
                 */
                do_action('xprofile_fields_saved_field', $field);
                $groups = bp_xprofile_get_groups();
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
开发者ID:espellcaste,项目名称:BuddyPress,代码行数:81,代码来源:bp-xprofile-admin.php


注:本文中的BP_XProfile_Field::set_member_types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。