Kentico CMS 6.0 Developer's Guide

Managing contact lists

Managing contact lists

Previous topic Next topic Mail us feedback on this topic!  

Managing contact lists

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example adds the cmseditor user to the current user's contact list.

 

private bool AddUserToContactList()

{

  // Gets "cmseditor" UserInfo object

  UserInfo user = UserInfoProvider.GetUserInfo("cmseditor");

 

  if (!ContactListInfoProvider.IsInContactList(CMSContext.CurrentUser.UserID, user.UserID))

   {

      // Adds "cmseditor" to the current user's contact list

      ContactListInfoProvider.AddToContactList(CMSContext.CurrentUser.UserID, user.UserID);

 

      return true;

   }

 

  return false;

}

 

The following example removes the cmseditor user from the current user's contact list.

 

private bool RemoveUserFromContactList()

{

  // Gets "cmseditor" UserInfo object

  UserInfo user = UserInfoProvider.GetUserInfo("cmseditor");

 

  if (ContactListInfoProvider.IsInContactList(CMSContext.CurrentUser.UserID, user.UserID))

   {

      // Removes "cmseditor" from the current user's contact list

      ContactListInfoProvider.RemoveFromContactList(CMSContext.CurrentUser.UserID, user.UserID);

 

      return true;

   }

 

  return false;

}