Answers.Body: <p>I'd recommend you ignore the form name/class entirely and display the message based on whether the user has an admin-type role. Then you don't care how the lookup gets invoked, you just show it to administrators, and it's tied to the service lookup rather than the way it got triggered.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-28T11:43:23.493Z
Answers.Text: Thanks! I used this in the end as address data can be updated using a variety of forms.
Answers.UserDisplayName: Andrew West
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-28T15:00:22.297Z
Answers.Text: As a slightly tangential observation - external lookups can be unpredictable, so it's best to invoke them in a non-blocking way, e.g. either as a cron job or via ajax, or using the batch api.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-27T19:46:05.850Z
Answers.LastActivityDate: 2017-06-27T19:46:05.850Z
Answers.UserDisplayName: Alan Dixon
Answers.Body: <p>It's a little difficult from your question how these checks to external services are configured - but assuming this is a hook, I would use <code>hook_civicrm_postProcess</code> rather than a database-oriented hook, since you'll get the form name right in the parameters.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-27T05:30:25.363Z
Answers.LastActivityDate: 2017-06-27T05:30:25.363Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>Is it possible to detect whether a user is filling in a form in the front-end or the back-end? I want to display a status message for the latter, but I don't want it appearing for regular users using the front-end.</p>
  
  <p>I could check the URL manually, but I figure there must be a better way.</p>
  
  <p>Context is: whenever an address is updated we have various lookups to external services going on. It's useful to display an error to our staff if these lookups fail. But I don't want these being shown to regular users when they update their addresses.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-26T23:52:30.770Z
Comments.Text: any point suggesting you use two different forms (clone profile)? one for public, one for admin?
Comments.UserDisplayName: petednz - fuzion
Tags: <forms>
Title: How can I detect whether a form is being filled in via the admin pages, rather than via the front-end?
ThreadText: # How can I detect whether a form is being filled in via the admin pages, rather than via the front-end?
  
  (Asked by: username_0 on 2017-06-26)
  
  Is it possible to detect whether a user is filling in a form in the front-end or the back-end? I want to display a status message for the latter, but I don't want it appearing for regular users using the front-end.
  
  I could check the URL manually, but I figure there must be a better way.
  
  Context is: whenever an address is updated we have various lookups to external services going on. It's useful to display an error to our staff if these lookups fail. But I don't want these being shown to regular users when they update their addresses.
  
  **Tags:** forms
  
  > **Comments:**
  > **username_1**: any point suggesting you use two different forms (clone profile)? one for public, one for admin?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-06-27. Score: 2 | Accepted answer
  
  I'd recommend you ignore the form name/class entirely and display the message based on whether the user has an admin-type role. Then you don't care how the lookup gets invoked, you just show it to administrators, and it's tied to the service lookup rather than the way it got triggered.
  
  > **Comments:**
  > **username_0**: Thanks! I used this in the end as address data can be updated using a variety of forms.  
  > **username_2**: As a slightly tangential observation - external lookups can be unpredictable, so it's best to invoke them in a non-blocking way, e.g. either as a cron job or via ajax, or using the batch api.  
  
  ---
  
  ### Answer by username_3 on 2017-06-27. Score: 1
  
  It's a little difficult from your question how these checks to external services are configured - but assuming this is a hook, I would use `hook_civicrm_postProcess` rather than a database-oriented hook, since you'll get the form name right in the parameters.
  
  
  ---
  
  