Reference for BuddyPress Hashtags core functions available for developers.
Hashtag Processing
bpht_db_buddypress_hashtag_entry()
Records hashtag usage in the database.
bpht_db_buddypress_hashtag_entry( $ht_name, $ht_type, $post_id = '0' );
Parameters:
$ht_name(string) – The hashtag without #$ht_type(string) – Content type (‘buddypress’, ‘bbpress’, ‘post’, ‘page’)$post_id(int) – Content ID (activity ID, post ID, etc.)
Example:
// Record a hashtag from custom content
bpht_db_buddypress_hashtag_entry( 'WordPress', 'buddypress', 123 );
User Functions
bpht_get_user_hashtags()
Retrieves hashtags followed by a specific user.
$hashtags = bpht_get_user_hashtags( $user_id, $type = '' );
Parameters:
$user_id(int) – User ID (optional, defaults to current user)$type(string) – Content type filter (optional)
Returns: Array of hashtag objects or false
$user_hashtags = bpht_get_user_hashtags( 123, 'buddypress' );
if ( $user_hashtags ) {
foreach ( $user_hashtags as $hashtag ) {
echo '#' . $hashtag->hashtag_items . '<br>';
}
}
bpht_delete_user_hashtag()
Removes a hashtag from user’s follow list.
$result = bpht_delete_user_hashtag( $user_id, $tag );
Returns: (bool) Success status
Utility Functions
bpht_alpha_numeric_hashtags_enabled()
Checks if non-alphanumeric (Unicode) hashtags are allowed.
$enabled = bpht_alpha_numeric_hashtags_enabled();
// Returns: (bool) True if enabled
bpht_is_valid_hashtag()
Validates if a hashtag is valid (not emoji or invalid sequence).
$is_valid = bpht_is_valid_hashtag( $hashtag, $context = 'activity' );
bpht_is_profanity_hashtag()
Checks if a hashtag is in the profanity blocklist. Requires BuddyPress Profanity plugin.
$is_blocked = bpht_is_profanity_hashtag( $hashtag );
// Returns: (bool) True if blocked
Settings Functions
$settings = get_option( 'bpht_general_settings', array() );
// Access individual settings
$min_length = isset( $settings['min_length'] ) ? $settings['min_length'] : 3;
$max_length = isset( $settings['max_length'] ) ? $settings['max_length'] : 16;
$suggestions_enabled = isset( $settings['enable_hashtag_suggestions'] )
&& $settings['enable_hashtag_suggestions'] === 'yes';
Available Setting Keys
| Key | Type | Description |
|---|---|---|
| min_length | int | Minimum hashtag length |
| max_length | int | Maximum hashtag length |
| allow_non_an_ht | bool | Allow Unicode hashtags |
| disable_on_bbpress | bool | Disable on bbPress |
| disable_on_blog_posts | bool | Disable on posts/pages |
| disable_follow_hashtag | bool | Disable follow feature |
| prevent_profanity_hashtags | bool | Enable profanity filter |
| enable_hashtag_suggestions | string | ‘yes’ or ‘no’ |
Constants
// Plugin version
BPHT_PLUGIN_VERSION
// Plugin file path
BPHT_PLUGIN_FILE
// Plugin basename
BPHT_PLUGIN_BASENAME
// Plugin URL
BPHT_PLUGIN_URL
// Plugin directory path
BPHT_PLUGIN_PATH
