• Resolved branstoker

    (@branstoker)


    Hi there!

    My theme contains a two in one Login/Register Popup modal that is executed with a class inside a link like this: Show Login popup.

    So i would first like to completly remove the “create an account” checkbox and add a class “show-login” to the “sign in” link.

    Any help would be greatly appreciated!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter branstoker

    (@branstoker)

    `<a class=”show-login” href=”#”>Sign in</a>

    Thats how the link looks alike…

    • This reply was modified 9 years, 2 months ago by branstoker.
    Plugin Author Greg Winiarski

    (@gwin)

    Hi, you would need to first replace the function which renders Account field, you can do that with following code

    
    add_action("init", "my_init");
    function my_init() {
      adverts_form_add_field("adverts_field_account", array(
        "renderer" => "my_adverts_field_account",
        "callback_save" => "adverts_save_multi",
        "callback_bind" => "adverts_bind_multi",
      ));
    }
    

    Next you will need to define my_adverts_field_account() function which basically will be customized copy of adverts_field_account() function.

    
    function my_adverts_field_account( $field ) {
        
        $fa = $field;
        
        if(is_user_logged_in() ) {
            
            $text = __('You are posting as <strong>%1$s</strong>. <br/>If you want to use a different account, please <a href="%2$s">logout</a>.', 'adverts');
            printf( '<div>'.$text.'</div>', wp_get_current_user()->display_name, wp_logout_url() );
            
        } else {
            
            $text = __('Create an account for me so I can manage all my ads from one place (password will be emailed to you) or <a href="%s">Sign In</a>', 'adverts');
            $text = sprintf( $text, wp_login_url( get_permalink() ) );
            
            $fa["options"] = array(
                array(
                    "value" => "1", 
                    "text" => $text
                )
            );
            
            adverts_field_checkbox($fa);
        }
        
    }
    

    The whole code you can add in your theme functions.php file.

    Thread Starter branstoker

    (@branstoker)

    Hi Greg!
    Thanks a lot for your fast response. I played around a bit with the code and i was able to manage it, except for removing the checkbox itself.
    I soluted this in css! If there’s a more elegant way to do it inside the functions.php let me know….:)

    Here’s my code:

    input#_adverts_account_1{
    display:none;
    }
    
    

    add_action(“init”, “my_init”);
    function my_init() {
    adverts_form_add_field(“adverts_field_account”, array(
    “renderer” => “my_adverts_field_account”,
    “callback_save” => “adverts_save_multi”,
    “callback_bind” => “adverts_bind_multi”,
    ));
    }
    function my_adverts_field_account( $field ) {

    $fa = $field;

    if(is_user_logged_in() ) {

    $text = __(‘Sie sind als %1$s angemeldet.’, ‘adverts’);
    printf( ‘<div>’.$text.'</div>’, wp_get_current_user()->display_name );

    } else {

    $text = __(‘Anmelden!‘, ‘adverts’);
    $text = sprintf( $text, wp_login_url( get_permalink() ) );

    $fa[“options”] = array(
    array(
    “value” => “1”,
    “text” => $text
    )
    );

    adverts_field_checkbox($fa);
    }
    }

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding class to “Sign In” link’ is closed to new replies.