bbp_add_user_subscription( int $user_id, int $object_id, string $type = 'post' )
Add a user subscription
Description Description
Parameters Parameters
- $user_id
-
(Optional) User id
- $object_id
-
(Optional) Object id
- $type
-
(Optional) Type of object being subscribed to
Default value: 'post'
Return Return
(bool) True if the object was added to user subscriptions, otherwise false
Source Source
File: includes/users/engagements.php
function bbp_add_user_subscription( $user_id = 0, $object_id = 0, $type = 'post' ) { // Bail if not enough info if ( empty( $user_id ) || empty( $object_id ) ) { return false; } // Bail if already subscribed if ( bbp_is_user_subscribed( $user_id, $object_id, $type ) ) { return false; } // Bail if add fails if ( ! bbp_add_user_to_object( $object_id, $user_id, '_bbp_subscription', $type ) ) { return false; } do_action( 'bbp_add_user_subscription', $user_id, $object_id, $type ); return true; }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | bbPress (r6544) Added $type parameter |
2.5.0 | Introduced. |