bbp_find_mentions

Searches through the content to locate usernames, designated by an @ sign.

Description

(bool|array) bbp_find_mentions( (string) $content = '' ); 

Returns (bool|array)

$usernames Existing usernames. False if no matches.

Parameters (1)

0. $content — Optional. (string) => ''
The content.

Usage

  1. if ( !function_exists( 'bbp_find_mentions' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/functions.php'; 
  3.  
  4. // The content. 
  5. $content = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_find_mentions($content); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/core/functions.php  
  1. function bbp_find_mentions( $content = '' ) { 
  2. $pattern = bbp_find_mentions_pattern(); 
  3. preg_match_all( $pattern, $content, $usernames ); 
  4. $usernames = array_unique( array_filter( $usernames[1] ) ); 
  5.  
  6. // Bail if no usernames 
  7. if ( empty( $usernames ) ) { 
  8. $usernames = false; 
  9.  
  10. return apply_filters( 'bbp_find_mentions', $usernames, $pattern, $content );