How to allow oEmbed parsing in MemberPress excerpts

Posted on

MemberPress is my plugin of choice for memberships and is what I use on this site.

In your MemberPress settings, if you have set an excerpt to appear for unauthorized visitors, YouTube video URLs and links to tweets will appear as is and will not get parsed by WordPress’ oEmbed unless the following is added:

add_filter( 'mepr-unauthorized-excerpt', 'add_autoembed_mepr_excerpt', 11, 3 );
/**
 * Run oembed on `mepr-unauthorized-excerpt` MemberPress filter to allow oembeds parsing in excerpts.
 */
function add_autoembed_mepr_excerpt( $excerpt, $post, $unauth ) {
    global $wp_embed;
    return $wp_embed->autoembed( $excerpt );
}

Source: MemberPress support.