Refined Search based on user´s role

Hello,

I use Refined Search in couple of my grids and I would like to hide or show the arrow-shaped icon (that control the refined search panel) base on the user´s role. I want to allow only users with “administrator” role to be allowed to see the arrow-shaped icon and use the Refined Search. All other users (students, professors, etc.) will not be allowed to use the Refined Search.

Any suggestion on how I could achieve that?

Thanks,

Daniel.

In onScriptInit

To remove Refined Search option

You can use

if ([role] != 'administrator') {
?>
	<script>
  	   $(document).ready(function() {
		   $('#div_int_fieldname1').hide();
		   $('#div_int_fieldname2').hide();
           ...;
	   });
	</script>
<?php
} else {	

}

I suppose that if you remove them all the Refined Search will disappear

4 Likes

Thnks [jlboutin60]. It helped me partially: If you remove all the fields, the entire Refined search do not dissapear.

I was trying and found this:

$(’#id_div_interativ_search_fields’).hide(); // Disables the refined search fields
$(’#id_div_interativ_search_content’).hide(); // Start in “Close” mode. Need 2 clicks to show entire refined search
$(’#app_int_search_toggle’).hide(); // Disables the arrow-shaped icon. Refined search stay enabled forever

If you include this 3 lines in “OnScriptInit” event, you can disable the entire Refined search. In fact, you can get the same result, including only the last 2 lines.

Suerte!

2 Likes

Dear rade,

Thanks for sharing such interesting code. I will give it a try and let you know if it worked into my code.

Regards,

Daniel.

Hi rade,

I’ve tried, but it doesn’t work
any idea?

image