Get topic and forum Activity Tracking status
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
If you are using Activity Tracking feature, and you need to get activity status for current user for any topic or forum in your own code, you can do it with the use of some custom code. The result of the calls are associative arrays that include all the same values GD bbPress Toolbox Pro uses to handle activity flags and other elements. If Activity Tracking is not active, this code can return invalid information.
Get forum status
This code example shows how to get the activity information array for a forum. Here we have $forum_id set to ID of 1, but in your code you can get forum ID in other ways.
$forum_id = 1; $activity = ActivityTracking::instance()->get_for_forum( $forum_id );
Resulting $activity array is activity status for current user for specified forum.
Get topic status
This code example shows how to get the activity information array for a topic. Here we have $topic_id set to ID of 1, but in your code you can get topic ID in other ways.
$topic_id = 1; $activity = ActivityTracking::instance()->get_for_topic( $topic_id );
Resulting $activity array is activity status for current user for specified topic.