I am using the OceanWP theme with the WP Job Manager plugin to build my job listing website.
When a user tries to 'Post a Job' when they are not logged in the WP Job Manager plugin shows a default login button which directs them to the default wp-login.php page: http://prntscr.com/pr86qn
But I wanted the user to be diverted to a new custom login/registration page I created as it does not have the 'Wordpress' logo on it and also allows users to register if they do not have an account.
When I clicked the "inspect element" option on this "sign in" button, I can see the link here: http://prntscr.com/pr8951
So I would like to change the link:
<a class="button" href="https://www.XXXXXXXXXX.co.uk/wp-login.php?redirect_to=https%3A%2F%2Fwww.XXXXXXXXXX.co.uk%2Fpost-a-job%2F">Sign in</a>
(I have XX'd out my website name as I would prefer it not to show in any google search results)
...so that it will direct the user to my new custom login/registration page instead.
Could anyone advise which file I could change this link from or if there is a better way of changing this link?
Thanks
This snippet will redirect all login links to the specified page (just replace /login-page/ on line 3 with the slug of your custom login page):
add_filter( 'login_url', 'my_login_page', 10, 2 );
function my_login_page( $login_url, $redirect ) {
return home_url( '/login-page/?redirect_to=' . $redirect );
}
Fix redirect issue
/** Log in redirect to previous page by logicdigger **/
// start global session for saving the referer url
function start_session() {
if(!session_id()) {
session_start();
}
}
add_action('init', 'start_session', 1);
// get the referer url and save it to the session
function redirect_url() {
if (! is_user_logged_in()) {
$_SESSION['referer_url'] = wp_get_referer();
} else {
session_destroy();
}
}
add_action( 'template_redirect', 'redirect_url' );
//login redirect to referer url
function login_redirect() {
if (isset($_SESSION['referer_url'])) {
wp_redirect($_SESSION['referer_url']);
} else {
wp_redirect(home_url());
}
}
add_filter('woocommerce_login_redirect', 'login_redirect', 1100, 2);
Try LoginPress Plugin to customize default login Page https://wordpress.org/plugins/loginpress/
I think you need a more advanced function originally mentioned here
Add this to your function file.
function possibly_redirect(){
global $pagenow;
if( 'wp-login.php' == $pagenow ) {
if ( isset( $_POST['wp-submit'] ) || // in case of LOGIN
( isset($_GET['action']) && $_GET['action']=='logout') || // in case of LOGOUT
( isset($_GET['checkemail']) && $_GET['checkemail']=='confirm') || // in case of LOST PASSWORD
( isset($_GET['checkemail']) && $_GET['checkemail']=='registered') ) return; // in case of REGISTER
else wp_redirect( home_url() ); // or wp_redirect(home_url('/login'));
exit();
}
}
add_action('init','possibly_redirect');
Please go through FTP
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.