0

I am trying to modify the login page using built in filters. The add_actions are working as expected, but I cannot get the filters to work. This is the code that I have in my functions.php:

add_filter( 'login_form_top', 'filter_top_login' );
function filter_top_login( $content )
{
    return 'This is what I want it to say!';
}

but it doesn't seem to be doing anything when I load the wp-login.php page. What am I doing wrong?

2

While login_form_top is a valid hook called by the wp_login_form function, wp_login_form is not used in wp-login.php, nor is that function used anywhere else that I can find. I greped my entire 3.5.1 install and found one reference to the function-- the place where it is defined. It does not appear to actually be used anywhere by the Core.

You will need to search the wp-login.php file for hooks, such as login_form, and try to do what you need with those hooks, or write your own login page (though it sounds like that is what you are trying to avoid).

1

You can use the login_message filter, which will show your text just above the login form:

add_filter( 'login_message', 'my_login_message' );

function my_login_message() {
    return 'This is my message';
}
0

login_form_top filter isn't called in wp-login.php.

The only hook I can see in wp-login.php in login form area is login_form (it's called on line 689). But it's placed after both inputs (login/password) so it's more like login_form_middle.

-1

just remove the $content variable,

    add_filter( 'login_form_top', 'filter_top_login' );
function filter_top_login()
{
    return 'This is what I want it to say!';
}
2
  • That makes no difference. As a couple of other people have noted, the login_form_top filter is not called on wp-login.php. The login_message filter can be used instead. – Simon Blackbourn Apr 30 '14 at 22:58
  • yes you are right. I think I havent read carefully, I used that filter in wp_login_form, but question is looking for wp-login.php. – ewroman May 1 '14 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.