I had to iterate through a bunch of *almost* working suggestions. This will grab the post content, check the custom fields, then drop any keys starting in _ or values ending in } (lets us avoid junk data in the calculation). The whole thing then gets appended to the original post content (passed by reference) and returned to the filter output.
Finally, I end by removing the filter because in the current version of Yoast’s plugin, wpseo_pre_analysis_post_content runs twice and screws up your density numbers as a result.
/**
* Add custom fields to Yoast SEO analysis
*/
add_filter('wpseo_pre_analysis_post_content', 'add_custom_to_yoast');
function add_custom_to_yoast( $content ) {
global $post;
$pid = $post->ID;
$custom = get_post_custom($pid);
unset($custom['_yoast_wpseo_focuskw']); // Don't count the keyword in the Yoast field!
foreach( $custom as $key => $value ) {
if( substr( $key, 0, 1 ) != '_' && substr( $value[0], -1) != '}' && !is_array($value[0]) && !empty($value[0])) {
$custom_content .= $value[0] . ' ';
}
}
$content = $content . ' ' . $custom_content;
return $content;
remove_filter('wpseo_pre_analysis_post_content', 'add_custom_to_yoast'); // don't let WP execute this twice
}
Remember: Yoast has not re-written the first tab in AJAX yet so it won’t reflect the changes. Everything else will though.