• 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 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Marcus (aka @msykes)

    (@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.

    Plugin Author Marcus (aka @msykes)

    (@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.

    Plugin Author Marcus (aka @msykes)

    (@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 4 replies - 1 through 4 (of 4 total)
  • The topic ‘ajax Login link in comments does not open “pop up”’ is closed to new replies.