wordpress wp_signon function not working -


I am using the wp_signon () function to login the user. I am doing this

$ creds = array ();

$ creds ['user_login'] = $ username;

$ creds ['user_password'] = $ password;

$ creds ['remember'] = true;

$ user = wp_signon ($ creds, false);

After logging in, I want to send the user to the home page.

But I am experiencing the following error:

WARNING: Header information can not be modified - Headers that have already been sent (e: \ xampp \ htdocs In the \ wpmoodle \ wp-content \ themes \ veten \ header.php: 12) e: \ xampp \ htdocs \ wpmoodle \ wp -include \ pluggable.php

wp_signon () code> needs to be run before sending any of your actual pages in the browser.

This is because wp_signon () does what your authentication cookies sets by outputting a "set cookie": ... ... header - if You see the 690 line of pluggable.php , where your error occurs, you will see that the line set is a cookie.

Therefore, because wp_signon () output header , you can not already send content - because the header There should always be output before the content.

However, the error indicates that you have already sent some output - 12 header.php , possibly the first HTML of some standard WordPress themes.

It basically indicates that you need to move your wp_signon () somewhere in wordpress processing, so this is an opportunity to get the contents of any page Produce its header before sending it.

Comments