Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Recker

    (@recker)

    No, i’m wrong again! The cache hadn’t cleared and it was still showing an old link to account via role redirect.

    Still haven’t managed to get it into a menu!

    Thread Starter Recker

    (@recker)

    I’ve managed to get it partly working!: protipsters.co.uk

    This is the code I’m using:

    /*Add Modal Menu Login/Logout*/
    function add_login_out_item_to_menu( $items, $args ){
    
    	//change theme location with your theme location name
    	if( is_admin() ||  $args->theme_location != 'primary' )
    		return $items; 
    
    		if( is_user_logged_in( ) )
        $link = '<a href="protipsters.co.uk/account" class="login">Account</a>';
    else
        $link = '<a href="protipsters.co.uk/subscription" class="login">Subscribe Now</a>';
    
    	$redirect = ( is_home() ) ? false : get_permalink();
    	if( is_user_logged_in( ) )
    		$link = do_shortcode('[modal_login login_text="Members Login" logout_text="Logout" logout_url="/"]');
    	else  $link = do_shortcode('[modal_login login_text="Members Login" logout_text="Logout" logout_url="/"]');
    
    	return $items.= '<li id="log-in-out-link" class="menu-item menu-type-link">'. $link . '</li>';
    }add_filter( 'wp_nav_menu_items', 'add_login_out_item_to_menu', 50, 2 );

    The issue I’m having now is that the Subscribe Now/Account button is stuck on Account all the time. It doesn’t change name, but it does appear to do what it’s meant to do!

    Thread Starter Recker

    (@recker)

    Where would a javascript error log be found?
    And I need the modal login/logout connected to the main menu. And it would be useful to have this to!

    Since I’m basically repeating code with a different layout, I don’t need this part again do i?

    function add_login_out_item_to_menu( $items, $args ){
    
    	//change theme location with your them location name
    	if( is_admin() ||  $args->theme_location != 'primary' )
    		return $items;

    Thanks for the help!
    – Jamie

    Thread Starter Recker

    (@recker)

    I tried that, It just showed a black screen! Didn’t load any of the site.
    Though it didn’t show any error code either, So It must be in the right direction!

    What do I need to do if I want to keep the login_text/logout_text?
    I need to changing the word just like the function you provided, but just linking to other pages rather than the shortcode.

    Sorry, I’m new to this 🙂

    So that part of the code would simply be:

    $link = http://www.mysite.com logout_url="/"]');
    else  $link = http://www.mysite.com logout_text="Uitloggen" logout_url="/"]');

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Is that correct?

    Hey,
    Thank you that worked perfectly!

    I was wondering if by any chance you knew how to tweak the code to do this:

    If not logged in show ‘Link A’
    When logged in show ‘link B’ in place,

    but rather then calling a shortcode it would be a page link.

    I tried it myself but I caused my entire site to error and break.
    So I thought I’d ask you!

    regards,
    Jamie

    Thread Starter Recker

    (@recker)

    What code am I looking for? This theme is coded much differently to others I have seen, I find navigating through it quite confusing!

    I’ll link each below to save time!

    Header.php
    [Code moderated as per the Forum Rules. Please use the pastebin]

    Footer.php only had something to do with bottom widget which doesn’t affect what I need.
    I hope you make more sense of it than I do, as most of it means nothing to me!

    Thanks again in advance!

    Thread Starter Recker

    (@recker)

    My single.php contains:

    <?php
    	get_header();
    	include(THEME_LIB.'/template_posts.php');
    	get_footer();
    ?>

    So, I’m guessing everything I need to chance would be in the template_posts.php?

    I’m new to recoding of bits like this, so sorry in advance if I’m slow!

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