RedirectAfterUpdate

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
drascom
Posts: 16
Joined: 2013-04-20 16:54

RedirectAfterUpdate

Post by drascom » 2013-05-05 23:03

i use $x->RedirectAfterInsert = "some page.php"; to change redirect but is there RedirectAfterUpdate or RedirectAfterDelete :idea:

User avatar
a.gneady
Site Admin
Posts: 1280
Joined: 2012-09-27 14:46
Contact:

Re: RedirectAfterUpdate

Post by a.gneady » 2013-05-11 20:21

No, though I plan to add these in future releases.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

drascom
Posts: 16
Joined: 2013-04-20 16:54

Re: RedirectAfterUpdate

Post by drascom » 2014-12-18 09:26

is there any improvements on this feature ?

rmloehmann
Posts: 10
Joined: 2014-03-31 22:28

Re: RedirectAfterUpdate

Post by rmloehmann » 2015-02-24 18:18

This does cause issues. The redirect to addnew after an update takes it to an update page where you save changes. If the user doesn't notice and enters new records, the records disappear. This can cause integrity issues for the program because people make these kind of mistakes all the time. Any plan on updating this soon to allow redirectafterupdate or redirectafterdelete?

udayvatturi
AppGini Super Hero
AppGini Super Hero
Posts: 85
Joined: 2014-06-14 03:08
Location: India
Contact:

Re: RedirectAfterUpdate

Post by udayvatturi » 2015-02-27 05:52

Hi,
Are you sure that redirecting after update will cause some issues related to permissions.
The issue might be some thing like, not updating user records table after update. But I think it may not be an issue, as record will be already inserted into user records table when inserted, redirecting after update may not cause a issue i think.

This may be bit confusing.

I think only Ahmad can tell what will be the issue if we put redirect statement after update..

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 351
Joined: 2013-03-21 04:37

Re: Redirect After Update

Post by peebee » 2016-09-12 23:48

Has anybody managed to work out a simple/safe method to redirect after update, preferably with a hook of course?

Looking to implement a redirect after update myself and I'm not too proud to borrow somebody else's work if already achieved. Thanks. :)

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: RedirectAfterUpdate

Post by DevGiu » 2016-09-13 12:04

Code: Select all

header("Location: index.php");
/Giuseppe
Professional Outsourcing Services

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 351
Joined: 2013-03-21 04:37

Re: RedirectAfterUpdate

Post by peebee » 2016-09-13 23:30

That was the first thing I tried but can't get it to work? Not sure why?

This snippet in datalist.php seems to take over and end result is always the same: update and end up on same record in detail view

Code: Select all

elseif($update_x != ''){
			$updated = call_user_func($this->TableName.'_update', $SelectedID);

			$update_status = 'record-updated-ok=' . rand();
			if($updated === false) $update_status = 'record-updated-error=' . rand();
Have you succeeded in redirect after update? How exactly?

bdurfee
Veteran Member
Posts: 32
Joined: 2013-02-07 17:44

Re: RedirectAfterUpdate

Post by bdurfee » 2017-08-25 18:41

I figured out a workaround. I needed the user to access the detail view to update their record and after saving be redirected to another page. The URL to edit the record is tablename_view.php?SelectedID=userid (where userid is the record ID). Therefore, add this to header.php on line 1.

Code: Select all

<?php
	$mi = getMemberInfo();
	if($_GET['SelectedID']){
		// show the page

	}elseif($mi['groupID'] == '5'){
		$return_url = 'mypage.php';
		header("Location: $return_url");
		
	}
?>
After submitting, SelectedID no longer exists in the URL so it redirects back to the page where I want them.

This allows you to set many different options regarding where you want users redirected and the conditions to do so.

User avatar
jmcgov
Veteran Member
Posts: 78
Joined: 2018-12-19 01:31
Location: Northern Ireland

Re: RedirectAfterUpdate

Post by jmcgov » 2019-01-09 22:43

This seems to work
- but you forfeit the record update audit (return = true does not get executed)
- you dont have to put in the condition, it is the exit that forces the redirect to be heeded (I think)

Code: Select all

	function cmembers_after_update($data, $memberInfo, &$args){
		if($_POST['update_x'] == '1'){
			header("Location: index.php"); 
			exit();
		}
		return TRUE;
	}

User avatar
jmcgov
Veteran Member
Posts: 78
Joined: 2018-12-19 01:31
Location: Northern Ireland

Re: RedirectAfterUpdate

Post by jmcgov » 2019-01-10 09:51

Mmh, you probably could do a manual record update audit edit

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: RedirectAfterUpdate

Post by AhmedBR » 2022-07-31 01:33

The user does not get the usual success message after saving either!
Is there a way to get this message before exit? that would be nice
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: RedirectAfterUpdate

Post by AhmedBR » 2022-07-31 11:21

I changed the code to this:

Code: Select all

header("Location: tableName_view.php?SelectedID={$data['selectedID']}"); 
			exit();
at least the user will stay on the same page, and clicking refresh will not resubmit the record.
I just miss the return true message.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

selectsteel
Posts: 26
Joined: 2013-09-23 14:14

Re: RedirectAfterUpdate

Post by selectsteel » 2022-08-16 20:57

AhmedBR where did you put that code?

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: RedirectAfterUpdate

Post by AhmedBR » 2022-08-16 22:36

function after update
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

Post Reply