BP_REST_XProfile_Fields_Endpoint::get_item_schema()

Get the XProfile field schema, conforming to JSON Schema.

Description

Return

(array)

Source

File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php

1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
public function get_item_schema() {
    $schema = array(
        '$schema'    => 'http://json-schema.org/draft-04/schema#',
        'title'      => 'bp_xprofile_field',
        'type'       => 'object',
        'properties' => array(
            'id'                => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'A unique numeric ID for the profile field.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'group_id'          => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The ID of the group the field is part of.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'parent_id'         => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The ID of the parent field.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'type'              => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The type for the profile field.', 'buddyboss' ),
                'type'        => 'string',
                'enum'        => buddypress()->profile->field_types,
                'arg_options' => array(
                    'sanitize_callback' => 'sanitize_key',
                ),
            ),
            'name'              => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The name of the profile field.', 'buddyboss' ),
                'type'        => 'string',
                'arg_options' => array(
                    'sanitize_callback' => 'sanitize_text_field',
                ),
            ),
            'alternate_name'    => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The alternate name of the profile field.', 'buddyboss' ),
                'type'        => 'string',
                'default'     => '',
                'arg_options' => array(
                    'sanitize_callback' => 'sanitize_text_field',
                ),
            ),
            'description'       => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The description of the profile field.', 'buddyboss' ),
                'type'        => 'object',
                'arg_options' => array(
                    'sanitize_callback' => null,
                    // Note: sanitization implemented in self::prepare_item_for_database().
                    'validate_callback' => null,
                    // Note: validation implemented in self::prepare_item_for_database().
                ),
                'properties'  => array(
                    'raw'      => array(
                        'description' => __( 'Content for the profile field, as it exists in the database.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'edit' ),
                    ),
                    'rendered' => array(
                        'description' => __( 'HTML content for the profile field, transformed for display.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'embed', 'view', 'edit' ),
                        'readonly'    => true,
                    ),
                ),
            ),
            'is_required'       => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Whether the profile field must have a value.', 'buddyboss' ),
                'type'        => 'boolean',
            ),
            'can_delete'        => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Whether the profile field can be deleted or not.', 'buddyboss' ),
                'default'     => true,
                'type'        => 'boolean',
            ),
            'field_order'       => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The order of the profile field into the group of fields.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'option_order'      => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The order of the option into the profile field list of options', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'order_by'          => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The way profile field\'s options are ordered.', 'buddyboss' ),
                'default'     => 'asc',
                'type'        => 'string',
                'enum'        => array( 'asc', 'desc' ),
            ),
            'is_default_option' => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Whether the option is the default one for the profile field.', 'buddyboss' ),
                'type'        => 'boolean',
            ),
            'visibility_level'  => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Who may see the saved value for this profile field.', 'buddyboss' ),
                'default'     => 'public',
                'type'        => 'string',
                'enum'        => array_keys( bp_xprofile_get_visibility_levels() ),
            ),
            'options'           => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Options of the profile field.', 'buddyboss' ),
                'type'        => 'array',
                'readonly'    => true,
            ),
            'data'              => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The saved value for this profile field.', 'buddyboss' ),
                'type'        => 'object',
                'readonly'    => true,
                'properties'  => array(
                    'raw'          => array(
                        'description' => __( 'Value for the field, as it exists in the database.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'embed', 'view', 'edit' ),
                    ),
                    'unserialized' => array(
                        'description' => __( 'Unserialized value for the field, regular string will be casted as array.', 'buddyboss' ),
                        'type'        => 'array',
                        'context'     => array( 'embed', 'view', 'edit' ),
                        'readonly'    => true,
                    ),
                    'rendered'     => array(
                        'description' => __( 'HTML value for the field, transformed for display.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'embed', 'view', 'edit' ),
                        'readonly'    => true,
                    ),
                ),
            ),
        ),
    );
 
    /**
     * Filters the xprofile field schema.
     *
     * @param array $schema The endpoint schema.
     */
    return apply_filters( 'bp_rest_xprofile_field_schema', $this->add_additional_fields_schema( $schema ) );
}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.