How do i make a button visible only to admins?

How do i make a button visible only to admins?

Hello!

Fliplet has a screen template that enables a menu for viewing by admins only.

Check out the admin menu screen template.

Alternatively, you can use the developer options to apply code to a single button using the CSS and JavaScript tabs.

You will need to apply the following javascript:


Fliplet.Session.get().then(function onSessionRetrieved(session) {
  var user;
  if (session.entries.dataSource) {
    user = _.get(session, 'entries.dataSource.data');
  }

  if (user['User Role'] === 'Admin') {
    $('.btn.btn-primary').show();
  }
});

The above code assumes you have a user data source with the column “User Role” and any admins are marked as “Admin” in this column

You will then need to hide the button for everyone else using this CSS:


.btn.btn-primary{
display: none;
}