Asked 7 years ago
13 May 2017
Views 2472
jessica

jessica posted

how to remove redirect_to form wp_login.php link

every comment box we have link to sign in for user to comment

http://example.come/wp-login.php?redirect_to=other_url


using woocommerce , so i trying to find the link where it come from so i can remove redirect_to link from but did not get any file where i can remove the redirect_to form wp_login.php link ,

basically i found some issue with google webmaster tool . it have some crawl errors so i want to remove redirect_to from wp_login.php
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

if using woocommerce , go to wp-content/themes/your-theme-name/woocommerce

and find single-product folder and you in this folder you will find file single-product-reviews.php ,

and find the wp_login_url

you will see the full code

wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) )


above code will create login link with redirect_to
use simply


wp_login_url( )


to remove redirect_to form login link so it will be simply now wp-login.php


or if you dont find than add following code to your comment_form config array


 $comment_form['must_log_in'	] = '<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', 'uplift' ), wp_login_url() ) . '</p>';



we are overriding default must_log_in from function wp_login_url
Rasi

Rasi
answered Nov 30 '-1 00:00

wp-content/themes/your-theme-name/
comment.php

find for the code


				    'must_log_in'		   => '<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', 'uplift' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',


change

wp_login_url(apply_filters('the_permalink', get_permalink( ) )) 


to


wp_login_url() 


it will redirect_to form wp-login.php , from login url
shyam

shyam
answered Nov 30 '-1 00:00

File: wp-includes/general-template.php

find the function function wp_login_url


function wp_login_url($redirect = '', $force_reauth = false) {



put the first line in this function is

$redirect = ''


and now you dont need to go to find every link for login to modify it . its just one change will change all login link of wordpress and it remove redirect_to from all places.
Post Answer