• Sub_Zero

    (@sub_zero)


    Hi,

    When I try this code, the function won’t get loaded. At least I don’t get the echo message. How comes?

    function custom_login() {
    	$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);
    	echo '<h1>HELLO</h1>';
    }
    add_action( 'after_setup_theme', 'custom_login' );
Viewing 1 replies (of 1 total)
  • I think the after_setup_theme is happening well before any browser output occurs, so you won’t see the output echo.

    For a try just to confirm your code is run, try get_footer instead …

    Also see the plugin API action reference

Viewing 1 replies (of 1 total)

The topic ‘function can't get loaded’ is closed to new replies.