• Hi,

    I am looking to add a login form (html embed code) to a specific menu item in my menu bar. Any ideas as to how I can achieve this?

    Thank you in advance,

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve found this code in wpmudev.org

    add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
    function add_login_logout_link($items, $args) {
            ob_start();
            wp_loginout('index.php');
            $loginoutlink = ob_get_contents();
            ob_end_clean();
            $items .= '<li>'. $loginoutlink .'</li>';
        return $items;
    }

    One downside is that it adds the item to ALL menus in your site, if you know how to tweak that tell me please.

    Thread Starter iamrohan

    (@rohan-k)

    I managed to make it working using replacewith() function: https://www.w3schools.com/jquery/html_replacewith.asp
    by replacing the content of specific menu item with the login form.
    Hope this will help you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add login form to a specific menu item’ is closed to new replies.