Title: wp_get_note_mentioned_user_ids
Published: August 20, 2026

---

# wp_get_note_mentioned_user_ids( string $content ): int[]

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#wp--skip-link--target)

Extracts the mentioned user IDs from note content.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#description)󠁿

Mentions are stored as chips carrying the `wp-note-mention` class plus a `user-N`
class token holding the mentioned user’s ID: `<span class="wp-note-mention user-
N">@Name</span>`. Only elements that carry both classes are treated as mentions.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#parameters)󠁿

 `$content`stringrequired

Note (comment) content, as stored.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#return)󠁿

 int[] Unique, positive mentioned user IDs.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#source)󠁿

    ```php
    function wp_get_note_mentioned_user_ids( string $content ): array {
    	if ( ! str_contains( $content, 'wp-note-mention' ) ) {
    		return array();
    	}

    	$user_ids  = array();
    	$processor = new WP_HTML_Tag_Processor( $content );
    	while (
    		$processor->next_tag(
    			array(
    				'tag_name'   => 'SPAN',
    				'class_name' => 'wp-note-mention',
    			)
    		)
    	) {
    		foreach ( $processor->class_list() as $class_name ) {
    			if ( 1 === preg_match( '/^user-(\d+)$/', $class_name, $matches ) ) {
    				$user_id = (int) $matches[1];
    				if ( $user_id > 0 ) {
    					$user_ids[] = $user_id;
    				}
    				break;
    			}
    		}
    	}

    	return array_values( array_unique( $user_ids, SORT_NUMERIC ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/comment.php#L2607)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/comment.php#L2607-L2634)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_HTML_Tag_Processor::__construct()](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/__construct/)`wp-includes/html-api/class-wp-html-tag-processor.php` |

Constructor.

  |

| Used by | Description | 
| [wp_notify_note_mentions()](https://developer.wordpress.org/reference/functions/wp_notify_note_mentions/)`wp-includes/comment.php` |

Notifies mentioned users about a new note.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_note_mentioned_user_ids/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.1.0](https://developer.wordpress.org/reference/since/7.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_note_mentioned_user_ids%2F)
before being able to contribute a note or feedback.