Skip to main content
2 of 5
make it looks like code
niksmac
  • 7.7k
  • 3
  • 31
  • 69

access text format based on user role

i have one user role : developer who can able to access text format : developer_html programically

i searched and tried with lots of codes but failed everytime, i got this piece of code here https://api.acquia.com/api/drupal/modules!filter!filter.install/function/filter_update_7008/7 and also tried to edit according to my requirement but failed

<?php
function filter_update_7008() {>
// Build the list of permissions to grant.
$permissions = array();
foreach (filter_formats() as $format_id => $format) {
if ($permission = filter_permission_name($format)) {
 $permissions[] = $permission;
}
}
// Grant text format permissions to all roles that can 'administer filters'.
// Albeit anonymous users *should not* have the permission, we cannot presume
// that they do not or must not.
if ($roles = user_roles(FALSE, 'administer filters')) {
 foreach ($roles as $rid => $name) {
   user_role_grant_permissions($rid, $permissions);
   }
  }
?>

also this https://api.acquia.com/api/drupal/modules%21user%21user.module/function/user_role_grant_permissions/7

Somik
  • 75
  • 10