Community

Including rules validation during search

We needed to distribute some files to individual users through our site. Each file is meant exactly for one user. Hence we created the download pages using custom content type and added a field to identify the intended user. To restrict the users from going to unintended pages we wrote rules so that an error message will be displayed saying that the content is not accessible and to redirect to some other page.

Now the head ache is that, we need to add a search form to search all contents in the site. We need to display only the accessible contents in the result.

Kindly suggest a way so that we can avoid showing the inaccessible contents in the search results.

Comments

One option is to disable

One option is to disable search for this content type so that no one can search this content type and view protected data usingSearch Restrict Module.

Other option is that you use implement hook_node_access and check the node object for entity reference to check the user id with account variable user id and if they match then return allow else deny the access this will restrict the viewing of the content but yet the content will be listed in search result.

Hth,
Sadashiv.