User strategy for interfacing with User Engagements.

This strategy largely exists for backwards compatibility with bbPress 2.5, or installations that have not upgraded their databases to 2.6 or above.

Note: this strategy is going to be a bit less tidy than the others, because it needs to do weird things to maintain the 2.5 status-quo. Do not use this strategy as an example when building your own.

since 2.6.0 bbPress (r6844)
package bbPress
inherited_from \BBP_User_Engagements_Base

 Methods

Add a user id to an object.

add_user_to_object(integer $object_id = 0, integer $user_id = 0, string $meta_key = '', string $meta_type = 'post', boolean $unique = false) : boolean
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::add_user_to_object()

Parameters

$object_id

integer

The object id.

$user_id

integer

The user id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

$unique

boolean

Whether meta key should be unique to the object.

Returns

booleanReturns true on success, false on failure.

Add a user id to an object.

add_user_to_object(integer $object_id = 0, integer $user_id = 0, string $meta_key = '', string $meta_type = 'post', boolean $unique = false) : boolean
Inherited
since 2.6.0 bbPress (r6722)

Parameters

$object_id

integer

The object id.

$user_id

integer

The user id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

$unique

boolean

Whether meta key should be unique to the object.

Returns

booleanReturns true on success, false on failure.

Get the part of the query responsible for JOINing objects to relationships.

get_query(array $args = array(), $context_key = '', string $meta_key = '', string $meta_type = 'post') : array
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::get_query()

Parameters

$args

array

$context_key

$meta_key

string

$meta_type

string

Returns

array

Get the part of the query responsible for JOINing objects to relationships.

get_query(array $args = array(), $context_key = '', string $meta_key = '', string $meta_type = 'post') : array
Inherited
since 2.6.0 bbPress (r6737)

Parameters

$args

array

$context_key

$meta_key

string

$meta_type

string

Returns

array

Get users of an object.

get_users_for_object(integer $object_id = 0, string $meta_key = '', string $meta_type = 'post') : array

The database queries in this function were cached in bbPress versions older than 2.6, but no longer are to avoid cache pollution.

since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::get_users_for_object()

Parameters

$object_id

integer

The object id.

$meta_key

string

The key used to index this relationship.

$meta_type

string

The type of meta to look in.

Returns

arrayReturns ids of users.

Get users of an object.

get_users_for_object(integer $object_id = 0, string $meta_key = '', string $meta_type = 'post') : array
Inherited
since 2.6.0 bbPress (r6722)

Parameters

$object_id

integer

The object id.

$meta_key

string

The key used to index this relationship.

$meta_type

string

The type of meta to look in.

Returns

arrayReturns ids of users.

Remove all users from all objects.

remove_all_users_from_all_objects(string $meta_key = '', string $meta_type = 'post') : boolean
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::remove_all_users_from_all_objects()

Parameters

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove all users from all objects.

remove_all_users_from_all_objects(string $meta_key = '', string $meta_type = 'post') : boolean
Inherited
since 2.6.0 bbPress (r6722)

Parameters

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove an object from all users.

remove_object_from_all_users(integer $object_id = 0, string $meta_key = '', string $meta_type = 'post') : boolean
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::remove_object_from_all_users()

Parameters

$object_id

integer

The object id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove an object from all users.

remove_object_from_all_users(integer $object_id = 0, string $meta_key = '', string $meta_type = 'post') : boolean
Inherited
since 2.6.0 bbPress (r6722)

Parameters

$object_id

integer

The object id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove a user id from all objects.

remove_user_from_all_objects(integer $user_id = 0, string $meta_key = '', string $meta_type = 'post') : boolean
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::remove_user_from_all_objects()

Parameters

$user_id

integer

The user id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove a user id from all objects.

remove_user_from_all_objects(integer $user_id = 0, string $meta_key = '', string $meta_type = 'post') : boolean
Inherited
since 2.6.0 bbPress (r6722)

Parameters

$user_id

integer

The user id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove a user id from an object.

remove_user_from_object(integer $object_id = 0, integer $user_id = 0, string $meta_key = '', string $meta_type = 'post') : boolean
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::remove_user_from_object()

Parameters

$object_id

integer

The object id.

$user_id

integer

The user id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Remove a user id from an object.

remove_user_from_object(integer $object_id = 0, integer $user_id = 0, string $meta_key = '', string $meta_type = 'post') : boolean
Inherited
since 2.6.0 bbPress (r6722)

Parameters

$object_id

integer

The object id.

$user_id

integer

The user id.

$meta_key

string

The relationship key.

$meta_type

string

The relationship type (usually 'post').

Returns

booleanReturns true on success, false on failure.

Delete the user engagement cache for a given meta key and object ID.

cache_delete(string $meta_key = '', integer $object_id = 0) : mixed

This method exists to provide backwards compatibility with bbPress 2.5, which had caching surrounding the FIND_IN_SET queries in usermeta.

since 2.6.3 bbPress (r6991)

Parameters

$meta_key

string

$object_id

integer

Returns

mixedResults from cache delete.

Get the user engagement cache for a given meta key and object ID.

cache_get(string $meta_key = '', integer $object_id = 0) : mixed

This method exists to provide backwards compatibility with bbPress 2.5, which had caching surrounding the FIND_IN_SET queries in usermeta.

since 2.6.3 bbPress (r6991)

Parameters

$meta_key

string

$object_id

integer

Returns

mixedResults from cache get.

Set the user engagement cache for a given meta key and object ID.

cache_set(string $meta_key = '', integer $object_id = 0, $user_ids = array()) : mixed

This method exists to provide backwards compatibility with bbPress 2.5, which had caching surrounding the FIND_IN_SET queries in usermeta.

since 2.6.3 bbPress (r6991)

Parameters

$meta_key

string

$object_id

integer

$user_ids

Returns

mixedResults from cache set.

Private function to get a 2.5 compatible cache key.

get_cache_key(string $meta_key = '', integer $object_id = 0) : string

This method exists to provide backwards compatibility with bbPress 2.5, which had caching surrounding the FIND_IN_SET usermeta queries.

since 2.6.3 bbPress (r6991)

Parameters

$meta_key

string

$object_id

integer

Returns

string

Private function to map 2.6 meta keys to 2.5 user-option keys.

get_user_option_key(string $meta_key = '', integer $object_id = 0, boolean $prefix = false) : string
since 2.6.0 bbPress (r6844)

Parameters

$meta_key

string

$object_id

integer

$prefix

boolean

Returns

string

Turn a comma-separated string into an array of integers

parse_comma_list(string $results = '') : array
since 2.6.0 bbPress (r6844)

Parameters

$results

string

Returns

array

 Properties

 

Type of strategy being used.

$type : string

Default

'user'
since 2.6.0 bbPress (r6844)
inherited_from \BBP_User_Engagements_Base::type
 

Type of strategy being used.

$type : string

Default

''
since 2.6.0 bbPress (r6737)