There is any possibility to identify change in logged in user from Portal/Community User type to Site User type. Scenario is portal user being forced logged out through apex based on some logic but in UI that end user need to get pop up message, my idea is to provide message if I can identify change in user type!!.


Depends on your Site's architecture.

On a Single Page Application polling server data with Javascript, you could monitor the User.userType field with JavaScript's Time.setInterval and the Ajax Toolkit, by polling a custom apex page or apex rest webservice every 5 secs for example.

super complex code

Otherwise on a more classic Site, you could check each time your user loads a page what his type is then fire a javascript popup.

Something like this, in pseudo-visualforce

    <script> if ( true == {! $User.userType == 'guest' }) alert("logged off!"); </script>
  • As it runs continuous interval will it be any impact or performance issue? – Nazeer Ahamed Apr 17 '15 at 12:05
  • I updated my answer: what kind of architecture do you use ? – mdenavac Apr 22 '15 at 12:46
  • Thanks Martin, I was using Java script and wanted to check if anything else we can do without monitoring the user properties - looks like it is the only option. Thank you! – Nazeer Ahamed Apr 23 '15 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.