versolearning / meteor-intercom

Reactive intercom integration for Meteor
47 stars 15 forks source link

Hide Intercom messenger for certain roles. #24

Open sgoudie opened 9 years ago

sgoudie commented 9 years ago

We only want a certain set of users within the app to be intercom customers (and hide the widget to others). Essentially, admins are allowed to use Intercom and count as intercom users, regular users don't.

I've tried disabling the messenger in Intercom and using the following in the layout.onRendered, but the widget still shows. Any ideas?

var userId = Meteor.userId();
var intercomUser = Roles.userIsInRole(userId, ['orgAdmin']);

  if (intercomUser) {
    IntercomSettings.widget = {
      activator: "#IntercomDefaultWidget"
    };
    console.log("Intercom user");
  } else {
    console.log("Not Intercom user");
  }
zol commented 8 years ago

I don't have any advice as I'm not an advanced intercom user. Sorry.

dburles commented 8 years ago

@sgoudie a PR is welcome if others may also benefit from this feature