Im trying to redirect same page using wp_login_form(). this is my code
function loginform() {
if ( is_user_logged_in()){
echo '<p> <a href="'.esc_url(home_url('/my-dashboard/')).'" >'.esc_html( __( 'Thank you.! Please Go to dashboard', 'mytheme' )).'</a></p>';}
else{
$args = array('redirect' => home_url(), 'id_username' => 'user','id_password' => 'pass',);
wp_login_form( $args );}}
add_shortcode('login-form', 'loginform');
i chancged the default wp-login.php url by using this filter
add_filter( 'login_url', 'new_login_page', 10, 3 );
function new_login_page( $login_url, $redirect, $force_reauth ) {$login_page = esc_url(home_url( '/login/'));return add_query_arg( 'redirect_to', $redirect, $login_page );}
then called to non logged in users to log in current page they are in by adding this code to
echo '<a href="'. esc_url(wp_login_url( get_permalink())) .'"><span class="icon" ></span>'.esc_html( __( 'login', 'mytheme' )).'</a> ';
everything work , but after logged in it wont redirect to previous page.. any help? highly appreciate.. thank you :)