I want to make a plugin for my own WordPress website, in which if the login page of WordPress is accessed from a specific address, then it is shown, otherwise it is redirected to homepage.
Example:
if(current_page == login && ip_address != xxx.xxx.xxx.xxx)
redirect_to_homepage;
I have made a simple plugin that reads ip address of current visitor and can access current page url, but the plugin does not run on the login page. The plugin executes on all public pages like example.com/index.php, but not on example.com/wp-login.php
I assume that I should use:
add_action('template_redirect', 'ss_check_login');
so that I can redirect page before headers are sent. Am I correct?
How to execute a plugin (and its code) on WordPress login page.
And I want to know what add_action to use for redirection?
I do not want to use .htaacess.