Support » Plugin: Login With Ajax » ajax Login link in comments does not open “pop up”

  • chappiewu

    (@chappiewu)


    Hi,
    I am enjoying the plugin on my site using listable theme.
    On the comment form I would like people to be logged-in to comment
    the login link over the comment form opens the a new page and not the pop up modal
    should I change something in the php of the comment form ?
    Thank’s for your support

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Marcus

    (@netweblogic)

    Hi, since it’s in what I can only guess is Mandarin, I have no idea where to click to see comments 🙂

    That said, we don’t usually place the LWA login form in comments, so could unless you placed it there somehow, the link to log in isn’t ours, probably your theme.

    chappiewu

    (@chappiewu)

    My web site: https://www.hymmoto.tw

    I add the following in functions.php but not work form opens the a new page and not the pop up modal. Please help me, thks!

    add_filter( ‘login_url’, ‘login-with-ajax’);
    function lwa_js_vars( $link ) {
    /*whatever you need to do with the link*/
    return home_url(‘/plugins/login-with-ajax/’);
    }

    please link this POST https://www.hymmoto.tw/xmax-300-z1/ , and for example to login https://www.hymmoto.tw/wp-content/uploads/2019/08/photo.png

    Thank you!

    Plugin Author Marcus

    (@netweblogic)

    To me, it just redirects to another page.

    I’m not sure what this would do, as your filter doesn’t have anything to do with that function.

    Probably what you want to do is use login_with_ajax() function to generate a login link there in your theme HTML, not a filter, since that link isn’t using LWA in any way.

    chappiewu

    (@chappiewu)

    I have already put current theme functions.php restore default. Please you link again your find loging to WP default page. https://www.hymmoto.tw/xmax-300-z1/

    Do you think have other solution use login_with_ajax() function.php to generate a login link there in my theme HTML for comment login?

    Or can you provide my PHP full code for my theme funcitons.php?

    Thank you!

    Plugin Author Marcus

    (@netweblogic)

    I see it now, I get sent to the login page.

    Sorry, I don’t have the time to get into code. Basically, you’d want to edit the theme file that generates this:

    您必須登錄才能發表評論。

    And change the login link so it uses Login With AJAX php function with the modal template (the FAQ should show how to do this).

    As it’s a listable theme I think they extended in their theme as well.

    You can check at /wp-content/themes/listable/inc/integrations/login-with-ajax.php

    What you can do is to add the required classes on the links so that lwa js can trigger the modal.

    Code Is not tested but i think it should work.

    add_filter( 'comment_reply_link', 'update_link_html', 10, 4);
    function update_link_html($link, $args, $comment, $post)
    {
        $link = sprintf(
                '<li class="lwa"><a rel="nofollow" class="comment-reply-login   lwa-links-modal lwa-login-link" href="%s">%s</a></li>',
                esc_url( wp_login_url( get_permalink() ) ),
                $args['login_text']
        );
    
        return $link;
    }
    
    add_filter( 'comment_form_defaults', 'update_comment_link_html', 10, 1);
    function update_comment_link_html($defaults)
    {
        global $post;
        $post_id = $post->ID;
    
        $defaults['must_log_in'] = '<p class="must-log-in lwa">' . sprintf(
                /* translators: %s: login URL */
                                        __( 'You must be <a href="%s" class="lwa-links-modal">logged in</a> to post a comment.' ),
                wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) )
            ) . '</p>';
    
        return $defaults;
    
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.