You have to hook earlier in the request to log someone in, you can’t do it from a page template because, as the error says, headers have been sent to the browser already, so it’s too late at that point.
<?php
add_action('template_redirect', 'my_check_login');
function my_check_login(){
if( is_page('my-login-page') && isset($_POST['email']) ){
// check input and
// do my login stuff here
}
}
Related Posts:
- How to get Login Error messages on a custom template
- send_headers don’t work on wordpress multisite
- Get ‘Headers already sent’ error for the plugin I am creating when I try to login
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- How do i ‘deactivate’ a plugin only on a certain page template?
- force logged in user to stay in the dashboard
- Prevent WordPress from sending set-cookie http header
- Redirect default login page to a custom page [duplicate]
- Checking url from plugin [duplicate]
- How to create a custom wordpress plugin for a specific functionality?
- Update plugin from personal API
- Loading external page template and enqueue script from plugin causes 403 forbidden error
- Symlinked plugin directory doesn’t appear in Admin
- Where the Nickname is being used in WordPress
- How can I limit functionality in one version of a plugin?
- How can I include a setting that has a variable number of values in a settings page using register_setting?
- Adding dynamic section to WordPress
- Custom data-id wp_enqueue_script
- Yoast SEO blocking/re-initialising longer running process
- Add Fields with Sub-Fields to WP Job Manager
- template_redirect not being called when using ajax
- WordPress login with Phone Number [closed]
- How use %like% in sql statement wordpress
- Can I use a form in a dashboard widget?
- Is there a way to alter the order in which the plugins appear in the page?
- How to correctly detect accessing wp-content/uploads?
- How to trigger $_GET request within admin plugin page?
- How to ‘clone’ a wp plugin to make small changes
- MITM risk of not sanitizing?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- Change plugin main file name (that is currently in the repo)
- Edit Yoast SEO breadcrumbs output [closed]
- Enqueue WordPress plugin scripts below all other JS
- Using a post-signup hook to get user details
- Is there any kind of theme on WordPress to sell my own movies?
- wp_remote_get() returns 403 while file_get_contents() does not
- How to set add question capability for author role in wp pro quiz plugin
- Suggestions on Approach to New Plugin I’m Stuck On
- How to redirect users to their profile after they successfully edit their profile
- Insert Array in Plugin Database
- What is wordpress way to access a plugin’s classes/models to load custom post type data?
- Change wp-login to custom URL login page
- breadcrumb need to show all pages and subpages
- Widget’s container?
- I changed font of wordpress dashboard but it is slow!
- Get Every Key & Value from Array then Display All in New Line
- WordPress 5.4 – How to prevent to enter only certain values in custom field
- Creating a functionality plugin to edit seriously simple podcasting
- Plugin temporary files and files to download via FTP
- DB Query not working in Plugin
- Make plugin php file called directly aware of WordPress?
- sending different email notification while registration based on user role
- How to add credit card validation check to wordpress [closed]
- Next Previous Post in wordpress with previous / next link with title?
- How to use existing hook in twentytwelve to all theme of wordpress?
- How to get a notification when the plugin is installed?
- WordPress Post HTML after Posting
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- Settings options not showing up on Sub Menu page in WordPress plugin
- My plugin does not install correctly if a previous version is still installed
- unregister a sidebar widget
- Remove List Bullets
- Custom Meta box change size
- Could add_query_arg() redirect user to external site?
- How to set plugin auto-update Enabled by default?
- wp_insert_post not inserting post from XML
- The Build menu theme is frozen with the wordpress theme
- How to translate to spanish wordpress hardcoded content/files?
- what functions to use to resize images and create DB metadata for them after/during upload?
- Login/password protected “client page”
- How to Create a Learning Management Plugin in WordPress to Manage Courses [LMS]
- How to prevent redoing get_posts queries and make results available to other scripts?
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- Store admin page into variable
- WP Plugin CSS not being applied to page
- Overwriting Plugin’s Ajax callback function from theme
- How can I get the Post ID and Post Type within a Must Use Plugin?
- Unable to sync woocommerce variations
- Can’t find variable is_single in my jQuery plugin
- WordPress Cron function is not working
- WP internationalization not loaded
- Adding custom cron_schedule prior to wp_schedule_event
- Create plugin with form in post and submit it to specific form
- Storing values in Post Meta vs new tables
- Get page type to display content
- Widget redirecting to home page
- Capturing POST data
- Is an Office a custom post type [closed]
- How to add image for custom taxonomy
- I am using multi image metabox plugin but I did get how to display the images in templete?
- How to open author url linked to a new tab in settings page in the WordPress plugin list
- How can I properly sanitize the update_option in WordPress?
- Why is my menu page not being displayed?
- wp_handle_upload – specified file failed upload test
- how to make wordpress remember my choice
- Meta box not displaying on the plugin page
- wordpress admin-ajax bad request 400
- public custom posts not showing in my wordpress plugin