• Resolved Chuckie

    (@ajtruckle)


    Hi !

    Is it possible to have a checkbox that lets us tell the login form to use placeholder text?

    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    I’m sorry, I’m not sure what you mean…

    Thread Starter Chuckie

    (@ajtruckle)

    The input elements can have a placeholder attribute filled in which, when used, will show the text as a hint in the input box etc.

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Here’s an example:

    
    function add_placeholder_text_to_tml_fields() {
        if ( $user_login = tml_get_form_field( 'user_login', 'register' ) ) {
            $user_login->add_attribute( 'placeholder', 'Your username' );
        }
    }
    add_action( 'init', 'add_placeholder_text_to_tml_fields' );
    

    For reference, here at the form field names: https://docs.thememylogin.com/article/96-form-field-priorities

    Thread Starter Chuckie

    (@ajtruckle)

    Thanks. I tried to run this code and it did not appear to make any difference?

    Plugin Author Jeff Farthing

    (@jfarthing84)

    That example should have added a placeholder to the username entry on the registration form. Unless you are using email only registration?

    Thread Starter Chuckie

    (@ajtruckle)

    I am using a form. I will try again later and provide you a link.

    Thread Starter Chuckie

    (@ajtruckle)

    Here you are:

    https://www.publictalksoftware.co.uk/register

    The function is active (or should be).

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Where have you placed the code?

    Thread Starter Chuckie

    (@ajtruckle)

    My theme (Unos Business Premium) has a custom plugin “Hoot Custom Code” which by design is for putting your functions etc in to as it is guarenteed to execute at the right time.

    All my other filters and hooks are in this file.

    Thread Starter Chuckie

    (@ajtruckle)

    I found the problem:

    https://docs.thememylogin.com/article/122-tmlgetformfield

    The sample code provided for tml_get_form_field had the two properties the wrong way round. ??

    Thread Starter Chuckie

    (@ajtruckle)

    Why is it that:

       /* Register Form */
        if ( $user_login = tml_get_form_field( 'register', 'user_login' ) ) {
            $user_login->add_attribute( 'placeholder', 'Your username' );
        }
        if ( $user_email = tml_get_form_field( 'register', 'user_email' ) ) {
            $user_email->add_attribute( 'placeholder', 'Your email address' );
        }
        if ( $user_pass1 = tml_get_form_field( 'register', 'user_pass1' ) ) {
            $user_pass1->add_attribute( 'placeholder', 'Provide a password' );
        }
        if ( $user_pass2 = tml_get_form_field( 'register', 'user_pass2' ) ) {
            $user_pass2->add_attribute( 'placeholder', 'Retype your password' );
        }
    	
    	/* Login Form */
        if ( $user_login = tml_get_form_field( 'login', 'user_login' ) ) {
            $user_login->add_attribute( 'placeholder', 'Your username' );
        }

    The Register Form adds the placeholders but not the Login Form?

    Thread Starter Chuckie

    (@ajtruckle)

    Sorted!

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Whoops! For clarity, here is the proper code:

    
    function add_placeholder_text_to_tml_fields() {
        if ( $user_login = tml_get_form_field( 'register', 'user_login' ) ) {
            $user_login->add_attribute( 'placeholder', 'Your username' );
        }
    }
    add_action( 'init', 'add_placeholder_text_to_tml_fields' );
    
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Placeholders – Login Form’ is closed to new replies.