In drupal a have added a field event to display a event in a web page. When I'm connected I see my Event field. The problem is when a anymous see my page he don't view my rendered entity.

If I change the format of my field to 'label', I can select the option 'Show entity labels regardless of user access' and with this configuration everybody can see my field. Where can I find the same option with the "Rendered Entity" format?

I use CiviCRM 4.6, Drupal 7 with modules CiviCRM Entity, Entity Reference and Display Suite.


2 Answers 2


So out of the box, CiviCRM Entity enforces that user has a role with 'view event info' permission to see the rendered entity.

In your case, you could probably just grant anonymous users that permission

This can be modified by implementing hook_civicrm_entity_supported_info() in a custom module, where you can change what permissions are necessary to view entities, or you can specifiy a custom access callback handler

See civicrm_entity.api.php

See https://skvare.com/blog/civicrm-entity-customizing-and-adding-entity-types

Add the functions below to a custom module, replacing YOURMODULE with your module name.

The first implements hook_civicrm_entity_supported_info(). There you set a custom access callback for the event entity. In the callback, check for the view operation, if the event is_public property is not empty, meaning is 1, then check the user has 'view event info' permission. Any other operations and events will enforce 'administer CiviCRM' permission .. you could use another permission, like 'edit all events', or whatever.


function YOURMODULE_civicrm_entity_supported_info(&$supported_info) {
  $supported_info['civicrm_event']['permissions']['access callback'] = 'YOURMODULE_custom_event_access_callback';

function YOURMODULE_custom_event_access_callback($op, $entity_type, $entity, $account, $permissions) {
  // if $op is view and event is public, check if the user has 'view event info' permissions
  if($op == 'view' && !empty($entity->is_public)) {
    // see https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_access/7.x
    return user_access('view event info', $account);
  // For all other ops and non-public events, check for 'administer CiviCRM' permission
  else {
    return user_access('administer CiviCRM', $account);
  • updating answer, you could probably just give anonymous users the View Event Info permission Commented Sep 17, 2018 at 21:30
  • Thanks. It's works. And how could I limit the view only to public events?
    – PhilippeS
    Commented Sep 18, 2018 at 7:33
  • updated answer with instructions and code example Commented Sep 18, 2018 at 23:28

For Drupal 9/10, you need to add an event handler, something like

function mymodule_entity_type_build(&$entity_info) {
  if (isset($entity_info['civicrm_event'])) {
    $entity_info['civicrm_event']->setHandlerClass('access', 'Drupal\mymodule\Access\EventAccessControlHandler');

And add a new handler class at src/Access/EventAccessControlHandler.php


namespace Drupal\mymodule\Access;

use Drupal\civicrm_entity\CivicrmEntityAccessHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;

class EventAccessControlHandler extends CivicrmEntityAccessHandler {

   * {@inheritdoc}
  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    //Custom logic to grant access

    return parent::checkAccess($entity, $operation, $account);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.