Membership 2 – Public Open Graph

I use Membership 2 Pro but when I share the URL from a protected pages on Facebook shows Protected content. I understand why, but I need this to show the content the users will see. The protected content can show up just when they access the page in case they are not logged in as the member. Is there any way to achieve this so that the open graph information stays public even though the content stays protected?

  • Nahid
    • Tech Support

    Hey Daniel !

    Hope you are having a great day!

    Nahid here, following up from our last Live Chat session. I just heard back from the developers and unfortunately, it won’t be possible to show the post content if it is shared to Facebook or any other social media sites in case it is protected by Membership 2 at the moment. It needs to be unprotected to show the post meta information.

    However, as this feature looks interesting, I’m moving it to the Features and Feedback section of our forum, where more members can vote if they think it’d be useful and we might consider looking into it if it gets a good amount of attention.

    Hope this helps. Let me know if you need any further assistance regarding this for now. Thanks!



  • Daniel
    • Site Builder, Child of Zeus

    Actually that’d be one of the most important features I need right now, because I always share the pages.

    I know I could be using shortcodes, but would work for me, it would be too much work.

    Maybe if there’s is a way to not protect content when the request comes from facebook or others.

  • Daniel
    • Site Builder, Child of Zeus

    I came up with a solution. I don’t know if it’s the best way to do it, but I think could work for start

    add_filter('ms_model_plugin_get_access_info', function ($info) {
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'facebookexternalhit') !== false)
    $info['has_access'] = true;

    return $info;

    I also don’t know if it’s the safest solution. Please, if there’s some opennig for atacks, let me know!

  • Dimitris
    • Support Star

    Hello there Daniel,

    hope you’re doing good and appreciate the feedback here! :slight_smile:

    I’ve been advised by our devs and this seems to be legit! Good job! :clap:

    It could become hazardous, if someone pretend to be Facebook, sending a request with same headers. Can’t really check all of these calls though, as some IP validation should be made.

    Warm regards,


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.