Page 1 of 1

RedirectAfterUpdate

Posted: 2013-05-05 23:03
by drascom
i use $x->RedirectAfterInsert = "some page.php"; to change redirect but is there RedirectAfterUpdate or RedirectAfterDelete :idea:

Re: RedirectAfterUpdate

Posted: 2013-05-11 20:21
by a.gneady
No, though I plan to add these in future releases.

Re: RedirectAfterUpdate

Posted: 2014-12-18 09:26
by drascom
is there any improvements on this feature ?

Re: RedirectAfterUpdate

Posted: 2015-02-24 18:18
by rmloehmann
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?

Re: RedirectAfterUpdate

Posted: 2015-02-27 05:52
by udayvatturi
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..

Re: Redirect After Update

Posted: 2016-09-12 23:48
by peebee
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. :)

Re: RedirectAfterUpdate

Posted: 2016-09-13 12:04
by DevGiu

Code: Select all

header("Location: index.php");

Re: RedirectAfterUpdate

Posted: 2016-09-13 23:30
by peebee
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?

Re: RedirectAfterUpdate

Posted: 2017-08-25 18:41
by bdurfee
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.

Re: RedirectAfterUpdate

Posted: 2019-01-09 22:43
by jmcgov
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;
	}

Re: RedirectAfterUpdate

Posted: 2019-01-10 09:51
by jmcgov
Mmh, you probably could do a manual record update audit edit

Re: RedirectAfterUpdate

Posted: 2022-07-31 01:33
by AhmedBR
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

Re: RedirectAfterUpdate

Posted: 2022-07-31 11:21
by AhmedBR
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.

Re: RedirectAfterUpdate

Posted: 2022-08-16 20:57
by selectsteel
AhmedBR where did you put that code?

Re: RedirectAfterUpdate

Posted: 2022-08-16 22:36
by AhmedBR
function after update