---
title: Adding Previous Page Redirection Support to Custom Login Forms
description: "If you are using a WordPress custom login form or a login form from a plugin we currently do not integrate with, below is a code snippet to make our [user redirection after log in previous/referrer page](https://loginwp.com/wordpress-redirect-referrer-page-after-login/) feature work with it.…"
url: "https://loginwp.com/docs/previous-page-redirection-support-custom-login/"
updated: "2024-10-15"
category: Code Snippet / Developer
---

# Adding Previous Page Redirection Support to Custom Login Forms

If you are using a WordPress custom login form or a login form from a plugin we currently do not integrate with, below is a code snippet to make our [user redirection after log in previous/referrer page](https://loginwp.com/wordpress-redirect-referrer-page-after-login/) feature work with it.

```php
add_action('wp_head', function() {
    if(is_page(1817) && class_exists('LoginWPLibsodiumRedirectionsInit')) {
        LoginWPLibsodiumRedirectionsInit::get_instance()->save_previous_page();
    }
});
```

Don't forget to replace **1817** with the ID of your login page.

**How to get your login page ID:**

- Navigate to your WP Dashboard > Pages tab, hover your mouse over the desired page, or 'Edit.' Check the lower bottom, and you will find the 'post=ID' for your login page.
   ![](https://loginwp.com/wp-content/uploads/2022/01/Login-ID-1024x492.jpg)
