Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    If you call wp_login_form() with the argument 'echo'=>false, the form HTML is returned instead of echoed directly. Capture the returned HTML in a variable and use str_replace() to replace the default class with what you want, then echo the result.

    Thread Starter NovaSev

    (@novasev)

    I’ll see what i can do with that on my own – thank you for your reply 🙂

    Thread Starter NovaSev

    (@novasev)

    Can you walk me through it a bit more bcworkz? I’m horrid when it comes to PHP at the moment and I’ve searched for this for a while now with no luck.

    Moderator bcworkz

    (@bcworkz)

    I’m not sure what your current code looks like, so you’ll need to fill in the gaps. Something roughly like this:

    $form = wp_login_form( array(
       'echo'=>false,
    ));
    echo str_replace('button-primary', 'novasev_class', $form );

    Thread Starter NovaSev

    (@novasev)

    Okay, wouldn’t that replace the entire login form with this class though? I was thinking it would be something like this:

    // Add selector to loginout php code
    add_filter('loginout', 'loginout_selector');
    function loginout_selector($text) {
    		$selector = 'class="logging" ';
    		$text = str_replace('<a ', '<a '.$selector, $text);
    		return $text;
    }

    So that way, I’m just picking out the single element that I want to add a different class to (the button only) and the rest is left alone. I just don’t know how to find the stuff that I actually need far as the names for the button at this point.

    Moderator bcworkz

    (@bcworkz)

    I’m pretty sure the only place “button-primary” appears in the login form is the class for the submit button alone. Check the HTML source of the login form output to be sure. That will show you what you really need to search for for proper replacement. One way or another, there’s a way to achieve what your need by suppressing the echo.

    ‘loginout’ will not help with the login form itself, that filter is for the simple login or logout link, not the form. The login form function does not have a similar filter because one can suppress the echo and do what I am suggesting. (There are filters, but they do not give access to the form HTML)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Filters….I think…’ is closed to new replies.