WordPress.org

Ready to get started?Download WordPress

Forums

User Meta Manager
[resolved] Page restriction based on user meta (4 posts)

  1. dineshm89
    Member
    Posted 2 months ago #

    I am trying to restrict pages, based on User meta using the following code.

    [useraccess json='{"RoleMeta":"Admin", " RoleMeta":"Subscriber1"}' message="You need permission to view this content."]Restricted content.[/useraccess]

    If the meta_key (RoleMeta) is either of (Admin or Subscriber1) the page should be displayed or else not.

    "Admin" is able to view the page, but "Subscriber1" is not.

    If I change the code to below, then "Admin" is restricted access:
    [useraccess json='{"RoleMeta":"Subscriber1", " RoleMeta":"Admin"}' message="You need permission to view this content."]Restricted content.[/useraccess]

    I want to display the content for both of these meta_key values.
    Spent quite a lot of time, trying to figure out a way!!!!

    Help greatly appreciated.
    Thanks,
    Dinesh M

    https://wordpress.org/plugins/user-meta-manager/

  2. President McCheese
    Member
    Plugin Author

    Posted 1 month ago #

    Hi,

    This bug should be fixed in version 3.3.8.

    Thanks for posting!

  3. dineshm89
    Member
    Posted 1 month ago #

    Upgraded to 3.3.9.

    Still no luck.
    Kindly help.

    Tried below code for user with Admin access, but is not working...
    [useraccess json='{"RoleMeta":"Subscriber1","RoleMeta":"Admin"}' message="You need permission to view this content."]Restricted[/useraccess]

    But,
    [useraccess json='{"RoleMeta":"Admin","RoleMeta":"Subscriber1"}' message="You need permission to view this content."]Restricted[/useraccess]
    is working for RoleMeta=>Admin...

  4. President McCheese
    Member
    Plugin Author

    Posted 1 month ago #

    Please update to version 3.4.0, then change the format for your json code.

    [useraccess json='{"RoleMeta":"Admin"},{"RoleMeta":"Subscriber1"}' message="You need permission to view this content."]Restricted[/useraccess]

    As you can see I have enclosed each meta key/value pair in {brackets}.
    json='{"RoleMeta":"Admin"},{"RoleMeta":"Subscriber1"}'

Reply

You must log in to post.

About this Plugin

About this Topic