• I have this code in my functions.php child theme file.

    $login_url = site_url('wp-login.php');
    $items .= "<li class='sub-menu'><a href='$login_url' class='lwa-links-modal'>Log In</a></li>";

    It is part of a callback on the filter ‘wp_nav_menu_items’ to make a modal login launch from the primary menu using this plugin.

    However clicking on the ‘Log In’ link does nothing. Turning on firebug and looking at the console.log shows this error. “TypeError: target is undefined” and dumps the minimized code for login-with-ajax.js.

    Update: chrome debug console tab gives this error: “Uncaught TypeError: Cannot call method ‘reveal’ of undefined“, so apparently somethiing is undefined when used this way. Also I should add that this plugin works fine as modal from a link in the sidebar widget.

    Changing the class name from lwa-links-modal’ to anything else makes the “target” link active again which is the normal wp-login.php form.

    Has anyone else got this plugin to work as a modal popup from a menu item? If so what code did you use?

    Thanks, Ron

    https://www.ads-software.com/extend/plugins/login-with-ajax/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey Ron,

    i had the same problem and solved it in my case. The problem is, that die jQuery looks up for an element, that not exists. From the clicked Element it looks up for the Parent-Element with the class .lwa, i created an div with the class lwa around my link, but he also looks up for an element with the stored data “modal”. So the .lwa Container is not a Parent-Element of my primary menu item.

    However here is my solution, that works for me:

    file: wp-content/plugins/login-with-ajax/widget/login-with-ajax.js

    look up/ search for the following snippet:
    parents(".lwa").data("modal")

    replace it with the following:
    parents().find(".lwa").data("modal")

    unfortunately i have no idea, if that edit creates a memory leak or something that slows down… but it works for me.

    i hope i could help you a lil bit. ??

    patrick

    okay, i had the widget activated, so it works.
    you also need to copy the code from wp-content/wp-plugins/login-with-ajax/widget/modal/widget_out.php

    to your template. i created a extra menu item for the login so it also works.

    thats how my header.php navigation part looks:

    https://pastebin.com/yygX9Fqh

    patrick

    Thread Starter Ron Strilaeff

    (@ronstrilaeff)

    Thanks for this, and I see it is a LOT more complicated than I first thought. So, trying to figure out what you are talking about….

    1. Did you include an entire (display:none;) form in a menu item?
    2. What exactly are you referring to when you say “copy the code from … to your template”. I don’t have a template anywhere for this, but the plugin doc keeps referring to one.
    3. It works perfectly “out of the box” as a sidebar widget, but the whole point of making a menu item was to do the same thing while eliminating that sidebar widget. Do I still need to have the sidebar widget in place to make your technique work?
    4. What is the essential difference between wp_nav_menu (which you use) and wp_nav_menu_items (which I tried to use and works well for other things)?

    It’s OK if you don’t have the time to explain all this… I have no loyalty or commitment to this plugin. All I want is something like (the apparently abandoned) simplemodal-login (but without the show stopper “ERROR: OK” bug) That much simpler plugin does the job simply by including a specific class name in the login link like I tried to do in my original post here.

    Hey Ron,

    unfortunately i have right now not the time to explain it further, but i will do it this evening. but what i promise to you: my modal login in the primary menu works after a few “hacks”. when i click on my login-link i get the modal window with the Login-Form and the Registration link, what fade out the register-form inside the modal-window.

    but i think i will have a look at the simpelmodal-login plugin.

    i just want to tell this to you right now.

    patrick

    Really need a solution too. I just need to input a modal popup into this code:

    <a href="https://plus.google.com/abc" title="+1" class="topmenu-social pull-right"><i class="icon-google-plus icon-large"></i></a>

    So when a user clicks the icon it brings up my login/register modal.

    Can anyone help with this maybe?

    Hey,

    What i did to achieve a link anywhere i want to trigger the modal-login-window of this plugin are the following steps:

    In my case i want to show a Login-link next to the Primary menu.

    Here is the part of my header.php to output the Menu with the Modal-window login-link. (to copy that code should work)

    https://pastebin.com/nbPSFVAd
    (this part of code is located in my /theme/name/header.php fyi)

    Just copy that code where ever you want. The important thing is, that the Login-Link and all the forms are in a wrapper(div or something else) with the class “lwa”. I modified the form-codes, so it display all three form (register, password recovery, login) in the modal window. if you don’t want to show any like this, then just delete the it from the code.

    Thats pretty much all what i did, the achieve the working modal-login in the primary menu. I have only one issue, if the user entered a wrong username/password combination, the password recovery link have to clicked two times to show up the recovery form. if i fixed that, i will post it.

    If you need help, just ask.

    HI Maybach91 – have you fixed the problem with password recovery link? If so, could you please share the latest code? Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘using this from a primary menu item’ is closed to new replies.