Jump to content
Posted
  • Owner

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 -->
{{endif}}

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) ) }}
PLACE YOUR CONTENT HERE
{{endif}}

 


View full record

  • Views 506
  • Created
  • Last Reply

Featured Replies