[ 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: 1390 lines (46 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 43 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()
  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()
  xprofile_avatar_upload_dir()
  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()
  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()

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

return: BP_XProfile_Field|null Field object if found, otherwise null.
since: 1.1.0
since: 2.8.0 Added `$user_id` and `$get_data` parameters.
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`.

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

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

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.

return: mixed The profile field data.
since: 1.0.0
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

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.

return: bool True on success, false on failure.
since: 1.0.0
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.

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

return: bool True on success
since: 1.6.0
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 visibity setting should be.

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

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

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

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

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

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

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

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

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

return: string|bool The fetched random data for the user, or false if no data or no match.
since: 1.0.0
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.

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 ]

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

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

return: bool
since: 1.1.0
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.

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

xprofile_avatar_upload_dir( $directory = 'avatars', $user_id = 0 )   X-Ref
Setup the avatar upload directory for a user.

return: array Array containing the path, URL, and other helpful settings.
since: 1.0.0
param: string $directory The root directory name. Optional.
param: int    $user_id   The user ID. Optional.

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.

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

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

return: bool
since: 1.0.0
param: int $user_id ID of the user to sync.

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

since: 1.2.4
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.

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.

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

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.

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

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.

return: bool True on success, false on failure.
since: 1.5.0
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

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.

return: mixed Meta value if found. False on failure.
since: 1.5.0
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

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

return: bool|int Returns false on failure. On successful update of existing
since: 1.5.0
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

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

return: int|bool The meta ID on successful update, false on failure.
since: 2.0.0
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

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

return: bool|int
since: 1.5.0
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.

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

return: bool|int
since: 1.5.0
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.

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

return: bool|int
since: 1.5.0
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.

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

return: int Field ID.
since: 2.0.0

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

return: string The field name.
since: 1.5.0

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.

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

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

return: array
since: 1.6.0

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.

return: array An array of field ids that should be excluded from the profile query
since: 1.6.0
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.

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.

return: array An array of visibility levels hidden to the current user.
since: 1.8.2
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.

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.

return: array $field_ids The fields that match the requested visibility levels for the given user.
since: 1.6.0
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

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

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

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

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



Generated: Wed Dec 11 01:01:37 2019 Cross-referenced by PHPXref 0.7.1