How to redirect to a specific page when using the login widget

Members 3 posts 2 voices

  1. Hello,

    I’m using the login widget on the homepage and would like to send the user to the protected page when they login.

    If this is not a feature, could you help with changing the php in the appropriate widget file?

    Thank you,
    Lori

  2. I do not support changing the PHP of my plugins. You would lose those changes every time an update is released.

    However, WP has a filter on login_form_defaults, which you can set to change the default redirect URL for all login forms (specific login forms can overwrite this though).

    The following code will handle this:

    add_filter( 'login_form_defaults', 'th_login_form_defaults' );
    
    function th_login_form_defaults( $defaults ) {
    
    	$defaults['redirect'] = 'http://yoursite.com/page-you-want';
    
    	return $defaults;
    }

    Just change the URL to your preferred page.

  3. I do not support changing the PHP of my plugins. You would lose those changes every time an update is released.

    However, WP has a filter on login_form_defaults, which you can set to change the default redirect URL for all login forms (specific login forms can overwrite this though).

    The following code will handle this:

    add_filter( 'login_form_defaults', 'th_login_form_defaults' );
    
    function th_login_form_defaults( $defaults ) {
    
    	$defaults['redirect'] = 'http://yoursite.com/page-you-want';
    
    	return $defaults;
    }

    Just change the URL to your preferred page.