I'm not certain how to make the below class, which is called from a trigger on Chatter posts, (it prevents users from posting in Chatter, unless related to a group, or a subset of Objects) also evaluate for the user profile.
Basically, there are 'superusers' that should be able to post anywhere, while the rest are held to the below rules. So the logic would be "if the current user is "Business Super User" profile, then ignore the rest of the class. I believe I can evaluate the current user profile as the first IF statement?
public with sharing class ChatterPostValidation {
public static Boolean isChatterPostAllowed(FeedItem feedItem) {
//ParentName is the name of where the post is going
//e.g. "CollaborationGroup" means it's being posted to a chatter group
String ParentName = feedItem.ParentId.getSObjectType().getDescribe().getName();
//check if place being posted is one of the following:
//chatter group, account (firm), contact, deal
if ('CollaborationGroup'.Equals(ParentName)) {
return true;
}
if ('Account'.Equals(ParentName) ||
'Contact'.Equals(ParentName) ||
'Investment__c'.Equals(ParentName)) {
return true;
}
return false;
}
}