I want a particular membership level to have access to ONLY

I want a particular membership level to have access to ONLY the files stored in a particular directory. Also, the files should be protected, i.e. not be accessible by URL by non-members; only from within the membership level's home page.

Is there an add-on that will do this?

Thanks,

Steve

  • Kasia Swiderska
    • Support nomad

    Hello Steve,

    If files are accessible from WordPress level (they are in media library) then you still can use Media protection add-on with enabled option for protect individual files - so you will see new tab in the Protection rules "Media" and there will be list of all media files, so for specific ones you can set protection.

    Urls are also protected with this add-on.

    This will not work if files are outside the WordPress.

    kind regards,
    Kasia

  • Ash
    • WordPress Hacker

    Hello @ssteinerX

    I hope you are doing good.

    Media protection only seems to mask the actual URL of the file. Does that mean that, if someone were to discover the actual file's URL, they could still download it?

    You are right, media protection addon just masks the file url, it can't protect the actual url. So if anyone knows the actual file url of that file, he will be able to download it.

    Is there any documentation regarding the cookies set by Membership 2 Pro so that I can use them in my .htaccess files in the protected directories?

    M2 pro doesn't use any cookie to protect directory, you can try usual htaccess file to protect directories.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • ssteinerX
    • Design Lord, Child of Thor

    Is there any example code, using the M2 Pro API for validating that a user belongs to a particular membership before letting them through to a specific URL/Download?

    Having any member able to access download for any other user if they know the direct URL seems to be a huge security hole and I can't go live with this being true.

    Thanks,

    Steve

  • Kasia Swiderska
    • Support nomad

    Hello Steve,

    There is function that allows you to check if member has specific membership.

    if ( ms_has_membership() ) // Current user has ?*any*? membership?
    if ( ms_has_membership(100) ) // Current user has membership 100?
    if ( ms_has_membership(100,110) ) // Current user has membership 100 or 110?

    here is code snippet that shows how can you use it https://gist.github.com/bappi-d-great/81133871af98d5e5a7dd

    kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.