Support » Plugin: Media Library Assistant » Restrict Search Results Based On Membership Level

  • Resolved feelee

    (@feelee)


    Hi David,

    on my website I use the Paid Membership Pro plugin to restrict access to content based on different membership levels.

    The website has many images organized into galleries using the MLA plugin. I use the search form [mla_gallery s=”{+template:({+request:search-string+}|a-bad-term)+}”…. to allow users to search for images.

    The problem is that the search results show any user any image they searched for, regardless of their membership level (the images should instead only be view-able according a user’s membership level).

    Since any image is attached to a post that belongs to a specific category to which members might have access depending on their membership level, I was wondering whether the search function above could be modified so that search results would be tailored to a user’s membership level?

    Thank you for your help.
    Filippo

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your question and for the detailed description of your application.

    I don’t have a copy of the Paid Membership Pro plugin and I hope you understand that I cannot afford to purchase premium plugins and themes simply to support my own free plugin. However, I can think of two possible solutions for your application.

    First, can you tell me if the plugin filters the results of the built-in WordPress [gallery] shortcode? If so, you might be able to use MLA’s “Support for Other Gallery-generating Shortcodes” to accomplish your task. You can try simply adding mla_alt_shortcode=gallery to your existing shortcode(s) to see if that works. More information can be found in the “Support for Other Gallery-generating Shortcodes” section of the Settings/Media Library Assistant Documentation tab.

    If that does not solve your problem you can try developing a small custom plugin that filters the results returned by the [mla_gallery] shortcode, using the many hooks MLA provides for that purpose. This will require some PHP coding based on how Paid Membership Pro works. You may be able to adapt one of MLA Example Plugins for your task To find it, navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “user” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA Login-filtered Gallery Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and verify the example plugin as you would any other plugin. You can also click the “View” action if you just want to have a look at the source code.

    The “MLA Login-filtered Gallery Example” plugin was developed for an earlier support topic you might also find useful:

    exclude some files for non subcribed users

    The earlier topic includes an alternate solution for a similar task.

    I hope that gets you started on a solution for your application. I am marking this topic resolved, but please update it if you have problems or further questions regarding the above suggestions. Thanks for your interest in the MLA plugin.

    David,
    You can download the full version of Paid Memberships Pro from the repository.
    https://wordpress.org/plugins/paid-memberships-pro/
    🙂
    Kim

    Plugin Author David Lingren

    (@dglingren)

    Thanks, Kim, for alerting me to the availability of Paid Memberships Pro in the repository.

    @feelee – Filippo,

    If you still need help with this topic post an update here and I will investigate further. Thanks for your understanding and your patience.

    David,

    Do you think searches could be based on “role”? Then each membership level could get its own role (PMPro has a plugin that will do this)

    Kim W

    Plugin Author David Lingren

    (@dglingren)

    @kimwhite

    Thanks for your question. I will investigate further and post an update here when I have progress to report. You wrote “(PMPro has a plugin that will do this)“. Can you post a link to the specific plugin/addon you have in mind? I’ve installed the core PMP plugin you referenced earlier.

    Plugin Author David Lingren

    (@dglingren)

    I have opened a topic in the PMP support forum:

    Restricting Access to Media Library Items

    I have successfully modified the [mla_gallery] shortcode to filter out items assigned to “restricted” Categories.

    @feelee – I am not sure it is possible to filter out “any image is attached to a post that belongs to a specific category” as you originally proposed. Can you directly assign the attached items to the restricted Categories in your application?

    Thanks for your patience in awaiting progress on this issue.

    Plugin Author David Lingren

    (@dglingren)

    @kimwhite – Kim,
    @feelee – Filippo,

    I have uploaded a new MLA Development Version dated 20200621 that adds PMP support for “restricted Categories” to Media Library items. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    Once the Development Version is installed you can add support for the WordPress Categories taxonomy:

    • Navigate to the settings/Media Library Assistant General tab.
    • Scroll down to the “Taxonomy Support” section.
    • Check the box in the “Support” column to make the Categories taxonomy available for Media Library items.
    • Check the “Inline Edit” box to display the taxonomy in the Quick Edit and Bulk Edit areas.
    • Check other boxes depending on your preferences. There’s a description of each box at the bottom of the section.
    • Scroll to the bottom of the screen and click “Save Changes” to record your new option settings.

    Now you can assign Media Library items to categories available to various membership levels. The [mla_gallery] shortcode will apply the PMP filter to each gallery you display.

    It would be great if you could update your Development Version and give the new feature a try. Let me know how it works for you. Thanks for your patience and perseverance.

    Hi David,
    I’m very sorry I missed your updates to this issue.
    I just proceeded to install the dev version of the plugin and assigned a “restricted” category to a few images.
    It worked. Now those images don’t show up anymore in the search results for users that don’t have the required membership level.
    So, this is great news!
    As far as I understand, I will now have to manually assign categories to all the attachments in order to get the desired result, as it is not possible to filter out “any image that is attached to a post that belongs to a specific category”…
    Well, if there is no other way, I will proceed and do that.
    I would like to thank you and just confirm with you that I should keep the dev version of the plugin installed until the next update of the official version, if I’m correct?
    Thanks again!
    Have a good day!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update confirming the improvements I made in the Development Version.

    You wrote “I will now have to manually assign categories to all the attachments in order to get the desired result“. Yes, assigning categories is the only practical solution for your application. The code complexity and performance impact of the more sophisticated solution renders it impractical.

    Finally, you can continue to use the Development Version with confidence until the next MLA update automatically replaces it. I always do my best to ensure that any Development Version I post is of “release candidate” quality.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.