Basic custom Shortcode not working

This is the simple version of what im trying to accomplish

//add display_name shortcode
function name_shortcode( ){
    return "testshortcode";
}
function register_shortcodes(){
    add_shortcode('display-name', 'name_shortcode');
}
add_action( 'init', 'register_shortcodes');

Which isnt working, the short code gets added to a custom post type called email. Grab the content using

$email_body = get_the_content();

And then email it out. But on the email body, i still only see the [display-name] short code text, instead of the quick “testshortcode” i set up.

Eventually if i get this to work, i would like this actually grab the the actual users display name from a wp_user_query loop i have set up in a seperate chron job funtion to send out a list of reminder emails… but one step at a time.

Solutions Collecting From Web of "Basic custom Shortcode not working"

get_the_content returns the content as is without processing, it does not pass it through the filters that are used in the_content such as oembeds or shortcodes. This filter is also called the_content ( coincidence )

Instead use this:

$email_body = apply_filters( 'the_content', get_the_content() );