Forum

Thread tagged as: Problem, Error, Members

Re-direct no longer working after upgrading to Perch 3

I've just upgraded to Perch 3 and a re-direct I had on my register.php page no longer works.

I'm getting the error:

Fatal error: Call to undefined function perch_member_logged_in_redirect() in /var/sites/a/amso.online/public_html/learning-community/register.php on line 1

the start of my register.php file looks like this:

<?php include('../something/runtime.php'); ?><?php perch_member_logged_in_redirect('/learning-community/'); ?>
Richy Thomas

Richy Thomas 0 points

  • 4 years ago

Richy

That function doesn't exist that I am aware of. Did someone else build your site, cause they may have written a new function into the runtime which would have been deleted upon update.

No I put that redirect in. It was working until I updated. I guess I must have added something else into the runtime too.

The file was overwritten when you updated the app, which is why you should never modify the core files of an app.

When you modify core files the changes you make will be lost upon update of such app. If you need to add functionality to an app which you didnt create you need to do this in your php not the app

Ok I understand.

Any ideas how I can do what I want without editing any of the core files?

I basically want a re-direct so that if a member is logged in and they visit register.php again then they are re-directed to the members index.php page instead.

if (perch_member_logged_in()) {
    PerchUtil::redirect('my fancy url here');
}else{
    perch_member_login_form();
}

And that has to be right at the top of my page? Before any other code?

Yes, it has to be before anything is output to the page for redirect to work. Redirect will fail if headers are sent before redirect is called.