0

I need to rename some of the labels on the Sidebar Login form using the sidebar_login_widget_form_args" filter; I have been trying few days to do this without any success.

I would very much appreciate it if someone could point me in the right directions.

Specifically, I need to rename the "Login->" button to just "Log In", rename the "Username" to "Username:" and "Password" to "Password:"

Here's my code which doesn't work:

/* Sidebar Login Plugin - Change Form Labels
add_filter( 'sidebar_login_widget_form_args','my_sidebar_login_widget_form_args', 10, 2);
function my_sidebar_login_widget_form_args() {

if ( 'label_username' === 'Username' ) { return 'Username:'; }// Change Username Label
if ( 'label_password' === 'Password' ) { return 'Password:'; }// Change Password Label
if ( 'label_log_in' === 'Login →' ) { return 'Log In'; } // Change Login Button Label
}

Thank you very much for your help in advance.

  • All of your code snippet is currently commented out by never closed comment at start. If your actual code is like that - that would render it useless indeed. – Rarst Jan 9 '14 at 16:22
1

You probably need to check again how to use WordPress filter. On your code, you haven't used the variable what sidebar_login_widget_form_args will pass to your function as argument. Please check below -

/* Sidebar Login Plugin - Change Form Labels */
add_filter( 'sidebar_login_widget_form_args','my_sidebar_login_widget_form_args', 10, 2);
function my_sidebar_login_widget_form_args( $args ) {
    // this is how you will change the argument values, using key
    $args['label_username'] = 'My Username'; // Change Username Label
    $args['label_password'] = 'My Pass'; // Change Password Label
    $args['label_log_in'] = 'My Log In'; // Change Login Button Label

    // after filter is done, you will return it
    return $args;
}

And make sure, your first line opening comment tag has a closing. Check the difference of my line and yours.

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.