[MEMBERSHIP] protected image in custom search function

I'm currently making a website with a membership area, where i've developed a custom search function, to search via the wp_query function and thru outputting posts and attachments that are protected by a given membership rule.

That works fine, but when I'm trying to display an attachment, where the link has been obfuscated by the membership plugin, I can't use https://codex.wordpress.org/Function_Reference/wp_get_attachment_url as that function returns the real url to the attachment, which will not work after the link has been taken over by membership.

I hope you can point me in the right direction :slight_smile:
Thank you

  • Kris
    • Support

    Hi Dennis

    I'm pinging our developer right now. I believe, he will come up with his valuable feedback on this very soon. We will update you as soon as we get anything from him.

    Please keep in mind, our developers work around the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback. I will appreciate your patience :slight_smile:

    Kind Regards,

  • Dennis
    • New Recruit

    Hi Kris, i've waited for almost 1,5 months, the question is now starting to become whether my client has anymore patience to wait for an answer to this question rather than if i do... would you PLEASE find time to help me soon, the project i'm working on is due for delivery very soon!

  • Joel James
    • Developer

    Hey Dennis,

    Sorry for the delay and thank you for your patience :slight_smile:

    You can refer protect_download_content function in MS_Rule_Media_Model class to achieve this. I can see that you were trying to call the protect_download_content function as a static method, but it is not static. So you can use something like this,

    $ms_media_rule = MS_Factory::load( 'MS_Rule_Media_Model', null );
    $content = $ms_media_rule->protect_download_content( $content );

    This will replace all attachment URLs with protected URLs.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.