WordPress.org

Ready to get started?Download WordPress

Forums

User Meta Manager
[resolved] Multiple Meta Values for Restriction (3 posts)

  1. srhise
    Member
    Posted 2 years ago #

    I am invisioning using this plugin for a group of users. Let' say those users all have a custom user meta key of 'company' with various companies that can be added.

    If I was to restrict access to content based on the company key -> value pair, how would I set it up so multiple companies could access the same content. Can you pass multiple values into the shortcode?

    Thanks in advance for your help, would love to see if this approach may work.

    http://wordpress.org/extend/plugins/user-meta-manager/

  2. President McCheese
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    Currently, you can only use multiple user ids.
    [useraccess users="1 22 301" message="You do not have permission to view this content."]Restricted content.[/useraccess]

    I will change this in the next version so you can add multiple meta values.

    In the meantime, if you group the companies based upon their level of access, you would not need multiple values.

    For example:

    • access_levels
      • gold
        • Company 1
        • Company 2
        • Company 3
      • silver
        • Company 4
        • Company 5
        • Company 6
      • bronze
        • Company 7
        • Company 8
        • Company 9

    [useraccess key="access_levels" value="gold" message="You do not have permission to view this content."]Content for gold companies.[/useraccess]

  3. President McCheese
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    Version 1.5.3 allows you to list multiple meta keys and values in the json attribute. The list must be properly JSON encoded as seen below.

    [useraccess json='{"access_level":"gold","sub_level":"silver"}' message="You do not have permission to view this content."]Restricted content goes here.[/useraccess]

    The new json attribute -
    json='{"access_level":"gold", "sub_level":"silver"}'

    JSON formatting -
    {"meta_key":"meta_value", "meta_key":"meta_value", "meta_key":"meta_value"}

    Additionally, you could repeat the same meta key multiple times.
    json='{"access_level":"gold", "sub_level":"silver", "sub_level":"bronze", "sub_level":"aluminum-foil"}'

    Hope that helps!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.