function bp_xprofile_template($user_id, $profile_group_id)
 {
     if (!$profile_group_id) {
         if (!($this->groups = wp_cache_get('xprofile_groups', 'bp'))) {
             $this->groups = BP_XProfile_Group::get_all(true);
             wp_cache_set('xprofile_groups', $this->groups, 'bp');
         }
     } else {
         if (!($this->groups = wp_cache_get('xprofile_group_' . $profile_group_id, 'bp'))) {
             $this->groups = new BP_XProfile_Group($profile_group_id);
             wp_cache_set('xprofile_group_' . $profile_group_id, 'bp');
         }
         /* We need to put this single group into the same format as multiple group (an array) */
         $this->groups = array($this->groups);
     }
     $this->group_count = count($this->groups);
     $this->user_id = $user_id;
 }
예제 #2
0
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate($_POST)) {
            $field->name = wp_filter_kses($_POST['title']);
            $field->desc = wp_filter_kses($_POST['description']);
            $field->is_required = wp_filter_kses($_POST['required']);
            $field->is_public = wp_filter_kses($_POST['public']);
            $field->type = wp_filter_kses($_POST['fieldtype']);
            $field->order_by = wp_filter_kses($_POST["sort_order_{$field->type}"]);
            if (!$field->save()) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = BP_XProfile_Group::get_all();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}