When I try this code
$creds = array( 'user_login' => $_POST['benutzername'], 'user_password' => $_POST['passwort'], 'remember' => true );
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ): echo $user->get_error_message(); endif;
wp_set_current_user($user->ID);
return $user;
I get this message:
Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/formatting.php:4179) in /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/pluggable.php on line 925 Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/formatting.php:4179) in /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/pluggable.php on line 926 Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/formatting.php:4179) in /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/pluggable.php on line 927 Catchable fatal error: Object of class WP_User could not be converted to string in /home/httpd/vhosts/your-click.ch/httpdocs/wp-includes/shortcodes.php on line 286
I am using that code in shortcode.php. What's wrong with my code?