simple auth check for custom plugin

Can anyone give me an example snip of the code I can put in my header to make sure the user is authenticated before running the php code?

Much Appreciated!


If you’re creating a page that you want to run when a user is logged in it’s probably simpler to create an entry point and use this. See this page

If you need this to be separate from SuiteCRM for some reason then you’ll need to check the current user using the authenticated_user_id session variable. Ideally you would use the AuthenticationController to check the user is legitimate but this may require pulling in extra entry point code. See the loadUser method in include/MVC/SugarApplication.php for how SuiteCRM handles the auth check.


1 Like

Perfect, thanks!