I have added one extra publish target for some reason. I want only admins to see this.This has to be hidden in both the places (publish window and DB switcher) for non admins.
You can achieve this by removing
Read access to the
Publish Target for the users.
- Open the
Sitecore menu > Security Tools.
- Select the
Everyonerole from the
Roles and usersselector
- Select the option to remove
Inheritancefrom the targets you wish to restrict access to.
The target will now be removed from database switcher and as a Publishing target for your regular users. Any user which is an Administrator will still have these targets available, since admin role ignores all security settings.
If certain roles need to have these targets available, you can grant access to those specific roles by granting "Read" access to them.