• Skip to content
  • Skip to primary sidebar

MTZ - My Techno Zone

mytechnozone.com is a website where you can find Tutorials related to Blogging, Wordpress, Elementor, Woocommerce and many other web development related tips and tricks.

  • Home
  • Blogging
  • Website Development
  • Android
You are here: Home / Wordpress / How to redirect users to same page where user before login in WordPress

How to redirect users to same page where user before login in WordPress

Hello friends,

When we create any login or registration page then sometimes we need the functionality to redirect the users to the same page where they are before login.

So today I am going to show you How to redirect users to same page where users before login in WordPress. For this, we need to create this simple function and add it to WordPress’s functions.php file. You can find the functions.php file in your active theme folder.

if( !function_exists('mtz_user_login_redirect') ) {

	function mtz_user_login_redirect() {
	if ( isset( $_REQUEST['redirect_to'] ) ) {
        $redirect_to = $_REQUEST['redirect_to'];
	}
	return $redirect_to;

	}

add_filter('login_redirect','mtz_user_login_redirect',10,3);

That’s it. Just copy this function and paste it in the functions.php file.

Thanks

Filed Under: Wordpress

Reader Interactions

Primary Sidebar

Categories

  • affiliate marketing
  • Blogging
  • Crypto
  • Elementor
  • Interview Questions
  • jQuery
  • Make money online
  • Programming languages
  • React Interview Questions
  • Tutorials
  • Webhosting
  • Website Development
  • whatsapp
  • woocommerce
  • Wordpress

Recents blog posts

  • Write a program to gererate fabonicci series using PHP
  • Create a Random number generator program using PHP
  • Write a Prime number checker program using PHP

Quick links

  • Disclaimer
  • About me
  • Privacy Policy

© 2023 · mytechnozone.com