Hi, is there a way to get the current user with the Javascript helper?
I have built some filters and want to add the current user to the filter
get current member id
Re: get current member id
AppGini Helper Javascript Library
In NEXT version there will be a function for this:
Solution in standard AppGini
There are different ways to get it. I think the easiest would be:
Then you can use the variable currentMemberID in your javascript:
Pros
In NEXT version there will be a function for this:
Code: Select all
AppGiniHelper.getMemberID( function(memberID) { /* your code */ } );
There are different ways to get it. I think the easiest would be:
Code: Select all
<!-- file: hooks/header-extras.php -->
<script>
const currentMemberID = '<?=getLoggedMemberID()?>';
</script>
Code: Select all
// file: hooks/TABLENAME-dv.js
$j(document).ready(function(){
alert('Your are logged in as: ' + currentMemberID);
});
Pros
- Easy to integrate
- Will not be updated after session timeout
Usually you will be redirected to login page automatically after 60 seconds. But in between the currentMemberID will still hold the old value which was valid when page was loaded, but is invalid since session timeout. If you need to react to such changes you should use AJAX before every relevant action and fetch the current user from the server:
Code: Select all
// not tested jQuery.get('ajax_check_login.php', function(response) { /* your code here, for example disable buttons */ });
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: get current member id
this function has been rolled out with 2020/10 version.
See docs at the bottom of this page:
https://appgini.bizzworxx.de/products/j ... functions/
See docs at the bottom of this page:
https://appgini.bizzworxx.de/products/j ... functions/
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools