The data you’re seeing in the source code is structured data (often used for SEO purposes) in the form of JSON-LD. Given that deactivating the “All in One SEO” plugin seemed to solve the problem, it’s likely that the plugin is generating this data.
But if you don’t want to disable the entire plugin, you can use a filter to modify the output. This way, you can keep the benefits of the SEO plugin while ensuring that the usernames aren’t leaked in the source code.
Try adding this to your theme’s functions.php
file. It’s designed to filter out the username from the structured data:
function filter_json_ld_output( $data ) {
// Check if author data is set and unset it
if ( isset( $data['author'] ) ) {
unset( $data['author'] );
}
// Check if creator data is set and unset it
if ( isset( $data['creator'] ) ) {
unset( $data['creator'] );
}
return $data;
}
add_filter( 'aioseop_json_ld_data', 'filter_json_ld_output' );
This function checks if ‘author’ or ‘creator’ data is present in the JSON-LD output by the “All in One SEO” plugin and then removes it. This way, you still get the rest of the SEO benefits from the plugin without exposing the username.