Login directly to Table View

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Login directly to Table View

Post by Moh Youba » 2020-07-03 18:24

Hello team how are you doing here, I hope you all are doing great.

Please I need a help.

I have a project with table *registration*, how can I set my app that when users login the table *registration* open in *table view*

Thank you

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Login directly to Table View

Post by pbottcher » 2020-07-03 18:56

Hi,

you can use the hooks/__global.php -> login_ok function. just return the correct url.

See https://bigprof.com/appgini/help/advanc ... obal-hooks
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Login directly to Table View

Post by Moh Youba » 2020-07-03 19:33

Hi sir

Thank you for your help. Working fine.

Best regards

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: Login directly to Table View

Post by ronwill » 2020-07-08 23:57

I have used this method
pböttcher wrote:
2020-07-03 18:56
Hi,

you can use the hooks/__global.php -> login_ok function. just return the correct url.

See https://bigprof.com/appgini/help/advanc ... obal-hooks
With following code:

Code: Select all

	function login_ok($memberInfo, &$args){

        if($memberInfo['group']=="clients")
	return 'clients_view.php?SelectedID=#ID#';
        else
        return "";
It works fine, however can it be made more 'clever' so that if, as in my scenario a new user gets redirected to a registration form to complete. Then once a 'record' exists for that user, then the next time user logs in the default redirect (to index.php) is applied and not the redirect?
If no record exists (i.e. user did not save one on last login/visit) then the redirect still applies.

It's not a must have but would be nice if possible!
Cheers, Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Login directly to Table View

Post by pbottcher » 2020-07-09 05:23

Hi,

I assume you save the registration form in the database. So just add a check to see if there is an existing entry in the membership_userrecords for that user and that table you store the registration form in.
If a record exists, no need to do something, otherwise forward to the registration form.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: Login directly to Table View

Post by ronwill » 2020-07-09 10:11

Yes the record is saved in the database but I'm ot sure how to write the conditional check for this.
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: Login directly to Table View

Post by ronwill » 2020-07-09 11:03

I've been trying with this, but not getting it to work yet:

Code: Select all

	function login_ok($memberInfo, &$args){

   if($memberInfo['group']=="clients") 
	   $getrecordcount = sqlValue("select COUNT(customers) FROM membership_userrecords WHERE tableName = 'customers' AND memberID = '$memberid1' ");
if ($getrecordcount > 0) return 'index.php';
		else
		return "customers_view.php?SelectedID=#ID#";
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Login directly to Table View

Post by jsetzer » 2020-07-09 12:16

Code: Select all

// ...
$tableName = 'customers';
$sql = "SELECT COUNT(*) 
  FROM `membership_userrecords` WHERE `tableName` = '{$tableName}' 
  AND `memberID` = '{$memberInfo["username"]}'";
$getrecordcount = sqlValue($sql);
// ...
Kind regards,
<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 readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: Login directly to Table View

Post by ronwill » 2020-07-09 13:19

Thanks Jan,

As always your help and assistance is greatly appreciated, I've used your solution and my code looks like this now and all working perfectly.

Code: Select all

	function login_ok($memberInfo, &$args){
		
   if($memberInfo['group']=="clients") 
$tableName = 'customers';
$sql = "SELECT COUNT(*) 
  FROM `membership_userrecords` WHERE `tableName` = '{$tableName}' 
  AND `memberID` = '{$memberInfo["username"]}'";
$getrecordcount = sqlValue($sql);
if ($getrecordcount == 0) return 'customers_view.php?SelectedID=#ID#';
		else
if ($getrecordcount > 0) return "index.php";
It's a very good addition to my project as clients would become frustrated always ending up on the registration form (customers) when they have already completed one.

Many thanks once again,
Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: Login directly to Table View

Post by ronwill » 2020-07-09 14:34

Sorry I pasted wrong code solution in above (It works but not in all user cases as members of other groups also get sent to the redirect page even when they have already registered, code now covers all logins/groups with a redirect only when no registration has been completed - admin also have to register to avoid redirect).

This is now correct/working (for me) code:

Code: Select all

	function login_ok($memberInfo, &$args){
		
$tableName = 'customers';
$sql = "SELECT COUNT(*) 
  FROM `membership_userrecords` WHERE `tableName` = '{$tableName}' 
  AND `memberID` = '{$memberInfo["username"]}'";
$getrecordcount = sqlValue($sql);
if ($getrecordcount < 1) return 'customers_view.php?SelectedID=#ID#';
		else
return "";
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

Post Reply