# bbPress: Email the Admin About New Topics

> Sends the site admin (or a moderator address) an email with the title, author and link whenever a new forum topic is posted.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: bbpress, email, notifications
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bbpress-email-admin-new-topic/

## Code

```php
if ( ! function_exists( 'bbp_get_topic_permalink' ) ) {
    return;
}

$wpide_bbp_notify_to     = get_option( 'admin_email' );
$wpide_bbp_notify_forums = array();

add_action( 'bbp_new_topic', function ( $topic_id, $forum_id ) use ( $wpide_bbp_notify_to, $wpide_bbp_notify_forums ) {
    if ( $wpide_bbp_notify_forums && ! in_array( (int) $forum_id, $wpide_bbp_notify_forums, true ) ) {
        return;
    }

    wp_mail(
        $wpide_bbp_notify_to,
        sprintf( 'New topic in %s: %s', bbp_get_forum_title( $forum_id ), bbp_get_topic_title( $topic_id ) ),
        sprintf(
            "%s started a new topic.\n\n%s\n\n%s",
            bbp_get_topic_author_display_name( $topic_id ),
            wp_trim_words( wp_strip_all_tags( bbp_get_topic_content( $topic_id ) ), 60 ),
            bbp_get_topic_permalink( $topic_id )
        )
    );
}, 10, 2 );
```

## Notes

Limit it to some forums with $wpide_bbp_notify_forums; leave empty for all forums.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: Email the Admin About New Topics" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
