One more update. I kind of have it working.
I added an extension to my addin and set the OnStartup code as follows:
AddHandler My.ArcMap.Events.OpenDocument, AddressOf OpenOrNewDocument
AddHandler My.ArcMap.Events.NewDocument, AddressOf OpenOrNewDocument
The OpenOrNewDocument Sub is as follows:
Private Sub OpenOrNewDocument()
'hide buttons/tools for readonly user
If clsGlobals.intUserRole > 1 Then Exit Sub 'not read only user
Dim UID As New ESRI.ArcGIS.esriSystem.UID
Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem
UID.Value = My.ThisAddIn.IDs.btnPushToGeo
commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False)
commandItem.Delete()
UID.Value = My.ThisAddIn.IDs.tolCreateNew
commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False)
commandItem.Delete()
End Sub
I tried putting the code to hide the buttons in the OnStart routine of the extension, but ArcMap crashes with no error messages reported. This way my code is triggered when the user opens a map or goes to a new map. The first time the toolbar is turned on, all the buttons are visible (but I have them disabled).
If the user then opens an mxd, goes to a new one or closes and re-opens ArcMap (without closing the toolbar), the buttons/tools that should be hidden are hidden and stay hidden unless the user closes the toolbar and re-opens it.
If anyone reading this can tell me where to better implement this code so that it is executed when the toolbar is created, I would appreciate it.