Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Show entry only to people set using the Member custom field

    If you want a way to set who can see a specific entry where you need to be able to choose individuals rather than user groups, then this is how you can do that.

    First you need to add the custom field called "Member" to your database. This will allow you to select users, and you can set the field to allow one user or multiple users.

    In your template we can then use the common logic check found in the IPS guide:

    {{if in_array( member.member_id, array( 5, 28, 472 ) )}}
    	<!-- Shows if the member's ID is 5, 28 or 472 -->

    When we use the Member field we first need to ensure that we get the raw values that is the ID. This will give us a list of ID's that are separated by spaces. We will use implode and preg_split to change that into a useable comma separated list. Finally we change the code to use explode instead or array to get things working the way we want. The result looks like this:

    {{$ids = $record->customFieldDisplayByKey('member', 'raw');}}
    {{$list = implode(", ", preg_split("/[\s]+/", $ids));}}
    {{if in_array( member.member_id, explode(", ",$list) ) }}


    User Feedback

    Recommended Comments

    There are no comments to display.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...