BP_REST_XProfile_Fields_Endpoint::set_additional_field_properties( integer $field_id, WP_REST_Request $request )
Set additional field properties.
Description
Parameters
- $field_id
-
(Required) The profile field object ID.
- $request
-
(Required) The request sent to the API.
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php
public function set_additional_field_properties( $field_id = 0, WP_REST_Request $request ) { if ( ! $field_id ) { return; } // Get the edit schema. $schema = $this->get_endpoint_args_for_item_schema( $request->get_method() ); // Define default visibility property. if ( isset( $schema['default_visibility'] ) ) { $default_visibility = $schema['default_visibility']['default']; if ( $request['default_visibility'] ) { $default_visibility = $request['default_visibility']; } // Save the default visibility. bp_xprofile_update_field_meta( $field_id, 'default_visibility', $default_visibility ); } // Define allow custom visibility property. if ( isset( $schema['allow_custom_visibility'] ) ) { $allow_custom_visibility = $schema['allow_custom_visibility']['default']; if ( $request['allow_custom_visibility'] ) { $allow_custom_visibility = $request['allow_custom_visibility']; } // Save the default visibility. bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $allow_custom_visibility ); } // Define autolink property. if ( isset( $schema['do_autolink'] ) ) { $do_autolink = $schema['do_autolink']['default']; if ( $request['do_autolink'] ) { $do_autolink = $request['do_autolink']; } // Save the default visibility. bp_xprofile_update_field_meta( $field_id, 'do_autolink', $do_autolink ); } // Define alternate title property. if ( isset( $schema['alternate_name'] ) ) { $alternate_name = ( ! empty( $schema['alternate_name']['default'] ) ? $schema['alternate_name']['default'] : '' ); if ( $request['alternate_name'] ) { $alternate_name = $request['alternate_name']; } // Save the alternate name. bp_xprofile_update_field_meta( $field_id, 'alternate_name', $alternate_name ); } }
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.