If you are just trying to logout a user and redirect them back to the homepage, could you just use the wp_logout()
function?
So instead of this:
if ( is_page_template( 'templates/template-logout.php' ) ) {
$logout_url = wp_logout_url( home_url() );
wp_safe_redirect( $logout_url ); // Logout and Redirect to homepage
exit;
}
Your logic could just be:
if ( is_page_template( 'templates/template-logout.php' ) ) {
wp_logout();
}
Related Posts:
- wp_enqueue_script was called incorrectly
- Remove type attribute from script and style tags added by WordPress
- Define page template in wp_insert_post
- Add custom template page programmatically
- Define custom Page Template without its own .php file
- Logout redirect to current page – function
- Filter the query ONLY for the search results page
- Masking logout URL
- Logout/login redirect CSS issue
- How to display error messages using WP_Error class?
- Custom page template how to check is_page from functions.php?
- Remove Menu Page Giving Error
- Run Product Filter Javascript On Page Template
- Functions.php reverted to new one
- Programmatically set page template based on page ID
- How to make unique add_filter to the_content of specific page template files – so each template gets its own addition
- Adjust which tempalte a page uses with a function?
- How to specify which Gutenberg blocks are available in the editor for a page template
- how to change link of some wordpress pages
- Why is my Gutenberg block returning an error after initial save?
- Filtering posts by category name based on page’s slug
- Debugging with functions.php
- is_account_page() change to page slug
- How to enable template page only for a post id page
- Activate small php condition at footer over page template
- Get_template_part inside a folder
- Warning: : DOMDocument::loadHTML(): Empty string supplied as input in functions.php when adding classes to post images
- Parse error after modifying the template menu [closed]
- help I changed one currency in woocommerce and everything is ruined [closed]
- Need help getting a function to function
- Pass parameter to hooked function using custom page template
- different style sheet for just one page template
- Connecting to a 2nd DB gives me no results when querying
- debugging errors.. how to remedy?
- Functions Error: Impacting Galleries
- Logout Redirect and also WP-login.php Redirect
- Page Template Won’t Load Correct CSS File
- Strange error from functions.php files (wp_register_script)
- Add Login and logout buttons to top menu bar
- Show errormessages on wrong username/password on custom loginform?
- Function to check if custom page is used by page?
- Problems with functions.php! Error! [closed]
- Looking for Functions File that doesn’t Exist
- Unable to use get_page_by_title() more than once per page?
- functions.php pharse error on complete new install
- How to Override Page Template if URL matches query?
- Probleme shortcode with list author
- How Can I Create a Friendly Slug for a Dynamic Page?
- Enqueue script if not page template
- “Conditional query tags do not work before the query is run. Before > then, they always return false. “
- Pagination won’t work on custom page
- MCAPI.class.php showing some error
- I’m getting invalid taxonomy in init action
- Edit meta fields from within template
- Translation Function missing text-domain [closed]
- Sending Messages Back to the Template After Processing?
- is_page_template wont allow me to enqueue scripts
- What is wrong with functions.php? Fills error log with same error
- Random text changing to weird icons in both admin & front end
- jQuery HoverIntent is not a function
- How to use different jquery function of idangero swiper dependant on page template?
- create submenu page – error function not found or invalid function name
- Why does modifying my functions.php file always result in a server error
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Woocommerce – Checkout error message
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- Comment turned Invisible
- Template Redirect Function Only Working When Logged In
- Convert Image to Webp on upload without plugin
- How to run a function every 5 minutes?
- How to override admin-bar style
- Get Category and Excerpt From wp_get_recent_posts
- How do I properly register bootstrap JavaScript into WordPress functions.php?
- Manipulate Output of wp_list_something: select menu instead of li’s
- how to fix Warning: Use of undefined constant _ – assumed ‘_’ (this will throw an Error in a future version of PHP)
- restore_current_blog required after switch_to_blog, if I use that in a function?
- ‘is’ functions and ‘get_query_var’ not working
- How to hide a plugin metabox for non admins when a user adds a new post
- Getting Featured Image Caption to Only Show if Populated
- How do I create page navigation linking to each H2 within the page? [closed]
- wp-admin won’t load after setting wp-login custom url
- Generate featured images old posts
- Use /prefix/postname as a slug in post_name?
- Send email to admin user when custom post type is created
- Test if a post exists by category and date
- Where to call my pagination function?
- How do I pull excerpts from pages?
- Check if a value exists in database table
- Add element to widgetpage
- Using functions.php to include code that’s processed inline
- why can’t i add front.css to my frontpage.php
- Are innerHTML elements visible to jQuery functions?
- how to display a page before the home page
- Get webpack to work on child theme
- Passing function arguments via a shortcode
- Hide ‘add to cart’ when certain value in dropdown is selected
- Help with with my function for wordpress
- Widget is displayed in two places
- Can site visitors view functions.php file?
- Loop on a wordpress Page instead of content coming from the WP text editor