[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-xprofile/ -> bp-xprofile-functions.php (summary)

BuddyPress XProfile Filters. Business functions are where all the magic happens in BuddyPress. They will handle the actual saving or manipulation of information. Usually they will hand off to a database class for data access, then return true or false on success or failure.

File Size: 1518 lines (50 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 47 functions

  bp_xprofile_get_groups()
  xprofile_insert_field_group()
  xprofile_get_field_group()
  xprofile_delete_field_group()
  xprofile_update_field_group_position()
  bp_xprofile_get_field_types()
  bp_xprofile_create_field_type()
  xprofile_insert_field()
  xprofile_get_field()
  bp_xprofile_get_field_type()
  xprofile_delete_field()
  xprofile_get_field_data()
  xprofile_set_field_data()
  xprofile_set_field_visibility_level()
  xprofile_get_field_visibility_level()
  xprofile_delete_field_data()
  xprofile_check_is_required_field()
  xprofile_get_field_id_from_name()
  xprofile_get_random_profile_data()
  xprofile_format_profile_field()
  xprofile_update_field_position()
  xprofile_override_user_fullnames()
  bp_xprofile_bp_user_query_search()
  xprofile_sync_wp_profile()
  xprofile_sync_bp_profile()
  xprofile_sync_wp_profile_on_single_field_set()
  xprofile_remove_data()
  xprofile_remove_data_on_delete_user()
  bp_xprofile_delete_meta()
  bp_xprofile_get_meta()
  bp_xprofile_update_meta()
  bp_xprofile_add_meta()
  bp_xprofile_update_fieldgroup_meta()
  bp_xprofile_update_field_meta()
  bp_xprofile_update_fielddata_meta()
  bp_xprofile_fullname_field_id()
  bp_xprofile_fullname_field_name()
  bp_xprofile_is_richtext_enabled_for_field()
  bp_xprofile_get_visibility_levels()
  bp_xprofile_get_hidden_fields_for_user()
  bp_xprofile_get_hidden_field_types_for_user()
  bp_xprofile_get_fields_by_visibility_levels()
  bp_xprofile_maybe_format_datebox_post_data()
  bp_xprofile_personal_data_exporter()
  bp_xprofile_get_wp_user_keys()
  bp_xprofile_get_signup_field_ids()
  bp_xprofile_signup_args()

Functions
Functions that are not part of a class:

bp_xprofile_get_groups( $args = array()   X-Ref
Fetch a set of field groups, populated with fields and field data.

Procedural wrapper for BP_XProfile_Group::get() method.

param: array $args See {@link BP_XProfile_Group::get()} for description of arguments.
since: 2.1.0
return: array $groups

xprofile_insert_field_group( $args = '' )   X-Ref
Insert a new profile field group.

param: array|string $args {
since: 1.0.0
return: boolean

xprofile_get_field_group( $field_group_id = 0 )   X-Ref
Get a specific profile field group.

param: int $field_group_id Field group ID to fetch.
since: 1.0.0
return: false|BP_XProfile_Group

xprofile_delete_field_group( $field_group_id = 0 )   X-Ref
Delete a specific profile field group.

param: int $field_group_id Field group ID to delete.
since: 1.0.0
return: boolean

xprofile_update_field_group_position( $field_group_id = 0, $position = 0 )   X-Ref
Update the position of a specific profile field group.

param: int $field_group_id Field group ID to update.
param: int $position       Field group position to update to.
since: 1.0.0
return: boolean

bp_xprofile_get_field_types()   X-Ref
Get details of all xprofile field types.

since: 2.0.0
return: array Key/value pairs (field type => class name).

bp_xprofile_create_field_type( $type )   X-Ref
Creates the specified field type object; used for validation and templating.

param: string $type Type of profile field to create. See {@link bp_xprofile_get_field_types()} for default core values.
since: 2.0.0
return: object $value If field type unknown, returns BP_XProfile_Field_Type_Textarea.

xprofile_insert_field( $args = '' )   X-Ref
Insert or update an xprofile field.

param: array|string $args {
since: 1.1.0
return: bool|int False on failure, ID of new field on success.

xprofile_get_field( $field, $user_id = null, $get_data = true )   X-Ref
Get a profile field object.

param: int|object $field    ID of the field or object representing field data.
param: int|null   $user_id  Optional. ID of the user associated with the field.
param: bool       $get_data Whether to fetch data for the specified `$user_id`.
since: 1.1.0
since: 2.8.0 Added `$user_id` and `$get_data` parameters.
return: BP_XProfile_Field|null Field object if found, otherwise null.

bp_xprofile_get_field_type( $field_id )   X-Ref
Get a profile Field Type object.

param: int $field_id ID of the field.
since: 8.0.0
return: BP_XProfile_Field_Type|null Field Type object if found, otherwise null.

xprofile_delete_field( $field_id )   X-Ref
Delete a profile field object.

param: int|object $field_id ID of the field or object representing field data.
since: 1.1.0
return: bool Whether or not the field was deleted.

xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )   X-Ref
Fetches profile data for a specific field for the user.

When the field value is serialized, this function unserializes and filters
each item in the array.

param: mixed  $field        The ID of the field, or the $name of the field.
param: int    $user_id      The ID of the user.
param: string $multi_format How should array data be returned? 'comma' if you want a
since: 1.0.0
return: mixed The profile field data.

xprofile_set_field_data( $field, $user_id, $value, $is_required = false )   X-Ref
A simple function to set profile data for a specific field for a specific user.

param: int|string $field       The ID of the field, or the $name of the field.
param: int        $user_id     The ID of the user.
param: mixed      $value       The value for the field you want to set for the user.
param: bool       $is_required Whether or not the field is required.
since: 1.0.0
return: bool True on success, false on failure.

xprofile_set_field_visibility_level( $field_id = 0, $user_id = 0, $visibility_level = '' )   X-Ref
Set the visibility level for this field.

param: int    $field_id         The ID of the xprofile field.
param: int    $user_id          The ID of the user to whom the data belongs.
param: string $visibility_level What the visibility setting should be.
since: 1.6.0
return: bool True on success

xprofile_get_field_visibility_level( $field_id = 0, $user_id = 0 )   X-Ref
Get the visibility level for a field.

param: int $field_id The ID of the xprofile field.
param: int $user_id The ID of the user to whom the data belongs.
since: 2.0.0
return: string

xprofile_delete_field_data( $field = '', $user_id = 0 )   X-Ref
Delete XProfile field data.

param: string $field   Field to delete.
param: int    $user_id User ID to delete field from.
since: 1.1.0
return: bool Whether or not the field was deleted.

xprofile_check_is_required_field( $field_id )   X-Ref
Check if field is a required field.

param: int $field_id ID of the field to check for.
since: 1.1.0
return: bool Whether or not field is required.

xprofile_get_field_id_from_name( $field_name )   X-Ref
Returns the ID for the field based on the field name.

param: string $field_name The name of the field to get the ID for.
since: 1.0.0
return: int|null $field_id on success, false on failure.

xprofile_get_random_profile_data( $user_id, $exclude_fullname = true )   X-Ref
Fetches a random piece of profile data for the user.

param: int  $user_id          User ID of the user to get random data for.
param: bool $exclude_fullname Optional; whether or not to exclude the full name field as random data.
since: 1.0.0
return: string|bool The fetched random data for the user, or false if no data or no match.

xprofile_format_profile_field( $field_type, $field_value )   X-Ref
Formats a profile field according to its type. [ TODO: Should really be moved to filters ]

param: string $field_type  The type of field: datebox, selectbox, textbox etc.
param: string $field_value The actual value.
since: 1.0.0
return: string|bool The formatted value, or false if value is empty.

xprofile_update_field_position( $field_id, $position, $field_group_id )   X-Ref
Update the field position for a provided field.

param: int $field_id       ID of the field to update.
param: int $position       Position to update the field to.
param: int $field_group_id Group ID for group the field is in.
since: 1.1.0
return: bool

xprofile_override_user_fullnames()   X-Ref
Replace the displayed and logged-in users fullnames with the xprofile name, if required.

The Members component uses the logged-in user's display_name to set the
value of buddypress()->loggedin_user->fullname. However, in cases where
profile sync is disabled, display_name may diverge from the xprofile
fullname field value, and the xprofile field should take precedence.

Runs at bp_setup_globals:100 to ensure that all components have loaded their
globals before attempting any overrides.

since: 2.0.0

bp_xprofile_bp_user_query_search( $sql, BP_User_Query $query )   X-Ref
When search_terms are passed to BP_User_Query, search against xprofile fields.

param: array         $sql   Clauses in the user_id SQL query.
param: BP_User_Query $query User query object.
since: 2.0.0
return: array

xprofile_sync_wp_profile( $user_id = 0, ...$args )   X-Ref
Syncs Xprofile data to the standard built in WordPress profile data.

param: int   $user_id ID of the user to sync.
param: array $args    Hook's additional arguments.
since: 1.0.0
since: 9.2.0 Adds the $args arguments to catch hook's additional arguments.
return: bool

xprofile_sync_bp_profile( &$errors, $update, &$user )   X-Ref
Syncs the standard built in WordPress profile data to XProfile.

param: object $errors Array of errors. Passed by reference.
param: bool   $update Whether or not being upated.
param: object $user   User object whose profile is being synced. Passed by reference.
since: 1.2.4

xprofile_sync_wp_profile_on_single_field_set( $data )   X-Ref
Update the WP display, last, and first name fields when the xprofile display name field is updated.

param: BP_XProfile_ProfileData $data Current instance of the profile data being saved.
since: 3.0.0

xprofile_remove_data( $user_id )   X-Ref
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.

param: int $user_id The ID of the deleted user.
since: 1.0.0

xprofile_remove_data_on_delete_user( $user_id )   X-Ref
Deletes user XProfile data on the 'delete_user' hook.

param: int $user_id The ID of the deleted user.
since: 6.0.0

bp_xprofile_delete_meta( $object_id, $object_type, $meta_key = false, $meta_value = false, $delete_all = false )   X-Ref
Delete a piece of xprofile metadata.

param: int         $object_id   ID of the object the metadata belongs to.
param: string      $object_type Type of object. 'group', 'field', or 'data'.
param: string|bool $meta_key    Key of the metadata being deleted. If omitted, all
param: mixed       $meta_value  Optional. If provided, only metadata that matches
param: bool        $delete_all  Optional. If true, delete matching metadata entries
since: 1.5.0
return: bool True on success, false on failure.

bp_xprofile_get_meta( $object_id, $object_type, $meta_key = '', $single = true )   X-Ref
Get a piece of xprofile metadata.

Note that the default value of $single is true, unlike in the case of the
underlying get_metadata() function. This is for backward compatibility.

param: int    $object_id   ID of the object the metadata belongs to.
param: string $object_type Type of object. 'group', 'field', or 'data'.
param: string $meta_key    Key of the metadata being fetched. If omitted, all
param: bool   $single      Optional. If true, return only the first value of the
since: 1.5.0
return: mixed An array of values if `$single` is false.

bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value, $prev_value = '' )   X-Ref
Update a piece of xprofile metadata.

param: int    $object_id   ID of the object the metadata belongs to.
param: string $object_type Type of object. 'group', 'field', or 'data'.
param: string $meta_key    Key of the metadata being updated.
param: string $meta_value  Value of the metadata being updated.
param: mixed  $prev_value  Optional. If specified, only update existing
since: 1.5.0
return: bool|int Returns false on failure. On successful update of existing

bp_xprofile_add_meta( $object_id, $object_type, $meta_key, $meta_value, $unique = false )   X-Ref
Add a piece of xprofile metadata.

param: int    $object_id   ID of the object the metadata belongs to.
param: string $object_type Type of object. 'group', 'field', or 'data'.
param: string $meta_key    Metadata key.
param: mixed  $meta_value  Metadata value.
param: bool   $unique      Optional. Whether to enforce a single metadata value
since: 2.0.0
return: int|bool The meta ID on successful update, false on failure.

bp_xprofile_update_fieldgroup_meta( $field_group_id, $meta_key, $meta_value )   X-Ref
Updates the fieldgroup metadata.

param: int    $field_group_id Group ID for the group field belongs to.
param: string $meta_key       Meta key to update.
param: string $meta_value     Meta value to update to.
since: 1.5.0
return: bool|int

bp_xprofile_update_field_meta( $field_id, $meta_key, $meta_value )   X-Ref
Updates the field metadata.

param: int    $field_id   Field ID to update.
param: string $meta_key   Meta key to update.
param: string $meta_value Meta value to update to.
since: 1.5.0
return: bool|int

bp_xprofile_update_fielddata_meta( $field_data_id, $meta_key, $meta_value )   X-Ref
Updates the fielddata metadata.

param: int    $field_data_id Field ID to update.
param: string $meta_key      Meta key to update.
param: string $meta_value    Meta value to update to.
since: 1.5.0
return: bool|int

bp_xprofile_fullname_field_id()   X-Ref
Return the field ID for the Full Name xprofile field.

since: 2.0.0
return: int Field ID.

bp_xprofile_fullname_field_name()   X-Ref
Return the field name for the Full Name xprofile field.

since: 1.5.0
return: string The field name.

bp_xprofile_is_richtext_enabled_for_field( $field_id = null )   X-Ref
Is rich text enabled for this profile field?

By default, rich text is enabled for textarea fields and disabled for all other field types.

param: int|null $field_id Optional. Default current field ID.
since: 2.4.0
return: bool

bp_xprofile_get_visibility_levels()   X-Ref
Get visibility levels out of the $bp global.

since: 1.6.0
return: array

bp_xprofile_get_hidden_fields_for_user( $displayed_user_id = 0, $current_user_id = 0 )   X-Ref
Get the ids of fields that are hidden for this displayed/loggedin user pair.

This is the function primarily responsible for profile field visibility. It works by determining
the relationship between the displayed_user (ie the profile owner) and the current_user (ie the
profile viewer). Then, based on that relationship, we query for the set of fields that should
be excluded from the profile loop.

param: int $displayed_user_id The id of the user the profile fields belong to.
param: int $current_user_id   The id of the user viewing the profile.
since: 1.6.0
return: array An array of field ids that should be excluded from the profile query

bp_xprofile_get_hidden_field_types_for_user( $displayed_user_id = 0, $current_user_id = 0 )   X-Ref
Get the visibility levels that should be hidden for this user pair.

Field visibility is determined based on the relationship between the
logged-in user, the displayed user, and the visibility setting for the
current field. (See bp_xprofile_get_hidden_fields_for_user().) This
utility function speeds up this matching by fetching the visibility levels
that should be hidden for the current user pair.

param: int $displayed_user_id The id of the user the profile fields belong to.
param: int $current_user_id   The id of the user viewing the profile.
since: 1.8.2
return: array An array of visibility levels hidden to the current user.

bp_xprofile_get_fields_by_visibility_levels( $user_id, $levels = array()   X-Ref
Fetch an array of the xprofile fields that a given user has marked with certain visibility levels.

param: int   $user_id The id of the profile owner.
param: array $levels  An array of visibility levels ('public', 'friends', 'loggedin', 'adminsonly' etc) to be
since: 1.6.0
return: array $field_ids The fields that match the requested visibility levels for the given user.

bp_xprofile_maybe_format_datebox_post_data( $field_id )   X-Ref
Formats datebox field values passed through a POST request.

param: int $field_id The id of the current field being looped through.
since: 2.8.0
return: void This function only changes the global $_POST that should contain

bp_xprofile_personal_data_exporter( $email_address )   X-Ref
Finds and exports personal data associated with an email address from the XProfile tables.

param: string $email_address  The users email address.
since: 4.0.0
return: array An array of personal data.

bp_xprofile_get_wp_user_keys()   X-Ref
Returns the list of supporterd WordPress field meta keys.

since: 8.0.0
return: string[] List of supported WordPress user keys.

bp_xprofile_get_signup_field_ids()   X-Ref
Returns the signup field IDs.

since: 8.0.0
return: int[] The signup field IDs.

bp_xprofile_signup_args( $extra = array()   X-Ref
Returns xProfile loop's signup arguments.

param: array $extra Optional extra arguments.
since: 8.0.0
return: array The xProfile loop's signup arguments.



Generated: Thu Dec 12 01:01:02 2024 Cross-referenced by PHPXref 0.7.1