function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anu Raj.ax1269Anu Raj.ax1269 

How to identify is loged in user is a community user or portal user.

Hi,

 I have created a manage package, in which I am displaying chatter feeds for login user. I want this feeds need to be displayed for only community user not for portal user, so i want to hide the component for portal users. So how can I identify is the loged in user is a community user or portal user.

 

Thanks 

Anu

Subhash GarhwalSubhash Garhwal

Hi Anu,

 

On user you have a checkbox field called 'IsPortalEnabled' if user is community or portal user than this checkbox is true, So you check for this field.

 

Thanks

 

Hit the Kudos button (star)  and Mark as solution if it post helps you

Anu Raj.ax1269Anu Raj.ax1269

Thanks for your reply. But i want to diffrencite is the log in use is community or portal. If portal i want to hide a component and for community user i want ot display the component with chatter feeds. 

Shiva Ramesh @ xcdhrShiva Ramesh @ xcdhr

Hi Anu

 

You can use getUserType method to find type of logged in user

 

String us = userinfo.getUserType(); 

 

Description The category of user license. Each UserType is associated with one or more UserLicense records. Each UserLicense is associated with one or more profiles. In API version 10.0 and later, valid values include:

  • Standard: user license. This user type also includes Salesforce Platform and Salesforce Platform One user licenses. Label is Standard.
  • PowerPartner: PRM user whose access is limited because he or she is a partner and typically accesses the application through a partner portal. Label is Partner.
  • CSPLitePortal: user whose access is limited because he or she is an organization's customer and accesses the application through aCustomer Portal. Label is High Volume Portal.
  • CustomerSuccess: user whose access is limited because he or she is an organization's customer and accesses the application through a Customer Portal. Label is Customer Portal User.
  • PowerCustomerSuccess: user whose access is limited because he or she is an organization's customer and accesses the application through a Customer Portal. Label is Customer Portal Manager. Users with this license type can view and edit data they directly own or data owned by or shared with users below them in the Customer Portal role hierarchy.
  • CsnOnly: user whose access to the application is limited to Chatter. This user type includes Chatter Free and Chatter moderator users. Label is Chatter Free.
Anu Raj.ax1269Anu Raj.ax1269

thanks, but i want to know whether the user have loged as portal user or community user. I want to identity which how he has login.

Akanksha JadhavAkanksha Jadhav

Whether logged in user is Community user or Portal user. 
 
Profile userProfile = [Select Name from Profile where Id =: userinfo.getProfileid() ];
String pname = userProfile.name;
System.debug(pname);

if(pname == 'Customer Community User') {
    //to do code
}
else if (pname == 'Customer Portal User'){
   //to do code
}

 

Thanks,

If this helps, marks it as solution.