PHP Redirect on Save
8 posts by 3 authors in: Forums > CMS Builder
Last Post: July 22, 2012 (RSS)
By nmsinc - May 14, 2012
Thanks - nmsinc
<?php
addFilter('section_init', '_plugin_redirectonsave', null, 2);
function _plugin_redirectonsave($tableName, $action) {
if ($tableName != 'claims_submission') { return; } // only run on accounts tabl
if ($action != 'list') { return; } // only run on list
$recordNum = @$_REQUEST['saved'];
$url = "http://www.claimscaddy.com/claims/listing.php?q=" . urlencode("Saved record $recordNum in $tableName");
redirectBrowserToURL($url);
}
?>
Re: [nmsinc] PHP Redirect on Save
By Jason - May 15, 2012
Which page would you want to return to? Normally in PHP you can use the $_SERVER['HTTP_REFERER'] variable. In CMS Builder, however, during a record_postsave, the past page will always be you edit page.
If you could tell us which page you are looking to get back to, and we can try to work something out.
Thanks,
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP Redirect on Save
By nmsinc - May 15, 2012
Upon submit, the plugin returns to the listing.php page. Now I have multiple listing pages so I now need the plugin to redirect to the listing page the user came from upon save!
The listing pages for return too are:
listing.php
active_claims_map.php
Thanks - nmsinc
Re: [nmsinc] PHP Redirect on Save
By Jason - May 16, 2012
I see, so your users are jumping from a front end list page, to an edit page inside CMS Builder, then redirecting them back to a front end list page.
One thing you can try is, on your list page, set a session variable with the name of the current file they're on.
for example:
<?php
$_SESSION['listPageUrl'] = "http://www.claimscaddy.com/claims/listing.php";
?>
Then in your plugin, you can use the value of $_SESSION['listPageUrl'] as the page your redirect to.
hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP Redirect on Save
By nmsinc - May 16, 2012
Re: [nmsinc] PHP Redirect on Save
By usadomains - July 22, 2012
When an admin logs in and edits a record, we get the following error;
Notice: Undefined index: listPageUrl in /homepublic_html/cmsadmin/plugins/redirect.php on line 17 redirectBrowserToURL: No url specified!
Re: [usadomains] PHP Redirect on Save
By Jason - July 22, 2012
If you're using the same code as above, you can get the plugin to stop running the function if the current user is an admin.
EXAMPLE:
function _plugin_redirectonsave($tableName, $action) {
global $CURRENT_USER;
if ($tableName != 'claims_submission') { return; } // only run on accounts tabl
if ($action != 'list') { return; } // only run on list
if ($CURRENT_USER['isAdmin']) { return; }
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] PHP Redirect on Save
By usadomains - July 22, 2012
Awsesome! That did the trick, it now redirects users, and ignores admins. perfect!
Really impressed that you took the time to reply over a weekend.