Archived topic
GPP Child Theme/ function.php/ Fatal error (user logout)
3 replies · Started by Jan on April 18, 2021
Hi David,
I'd like registered users to click a logout-link in the header menu and then get redirected to a success page.
I was wondering if you could take a look at the php-code-snippet that I have added to the function.php:
//Redirect after logout to logout page
add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
/**
* Allow logout without confirmation
*/
if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
$redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'https://webgefaehrte.de/mitglieder/abgemeldet';
$location = str_replace('&', '&', wp_logout_url($redirect_to));
header("Location: $location");
die;
}
}
?>
Debugging comes back with the following error unfortunately:
<br />
<b>Fatal error</b>: Uncaught Error: Call to undefined function add_filter() in [...][...]:10
Stack trace:
#0 {main}
thrown in <b>[...][...]</b> on line <b>10</b><br />
How would you go about fixing this error?
Thanks,
Jan
Hi Jan,
I don't believe the error comes from that specific function as it doesn't have the add_filter line in it as the error suggested.
I also tried adding that function in Code Snippet and it didn't trigger any errors:
https://www.screencast.com/t/0LlSuVpm0ky
Perhaps the error is coming from another function in your child theme?
Please keep in mind that we aren't able to help with custom functions that are unrelated to the theme itself at this time:
https://generatepress.com/what-support-includes/
If you need further help with this, I'd recommend starting a topic in a WordPress general forum like:
https://wordpress.stackexchange.com/
Hope this helps and thanks for your understanding :)
Hi Leo,
we managed to fix the error in the meantime.
The suggestion around Stackexchange war helpful ;-)
Best,
Jan
Glad to hear :)