WordPress.org

Forums

Simple Side Tab
[resolved] Show Simple Side Tab Only if Not Logged In - SOLUTION (2 posts)

  1. spearsonit
    Member
    Posted 1 year ago #

    Saw a previous post about this when I was looking for a way to hide the Simple Side Tab after a user logs in, but it's closed for further replies. Just wanted to post how I got this to work for anyone else looking to do the same.

    I changed:

    // set side of page for tab
    	if ($rum_sst_left_right == 'right') {
    		$rum_sst_left_right_location = 'rum_sst_right';
    	}else {
    		$rum_sst_left_right_location = 'rum_sst_left';
    	}
    
    	if(preg_match('/(?i)msie [7-8]/',$_SERVER['HTTP_USER_AGENT']))
    	{
    	    // if IE 7 or 8
    	    // Write HTML to render tab
    		echo '<a href="' . esc_url( $rum_sst_tab_url ) . '"' . $rum_sst_target_blank . '><div id="rum_sst_tab" class="rum_sst_contents less-ie-9 ' . $rum_sst_left_right_location . '">' . esc_html( $rum_sst_text_for_tab ) . '</div></a>';
    	}
    	else
    	{
    	   // if IE>8
    	   // Write HTML to render tab
    	   echo '<a href="' . esc_url( $rum_sst_tab_url ) . '"' . $rum_sst_target_blank . ' id="rum_sst_tab" class="rum_sst_contents ' . $rum_sst_left_right_location . '">' . esc_html( $rum_sst_text_for_tab ) . '</a>';
    	}
    }

    to:

    // set side of page for tab
    	if ($rum_sst_left_right == 'right') {
    		$rum_sst_left_right_location = 'rum_sst_right';
    	}else {
    		$rum_sst_left_right_location = 'rum_sst_left';
    	}
    	if ( is_user_logged_in() ) {
    
    } else {
    	if(preg_match('/(?i)msie [7-8]/',$_SERVER['HTTP_USER_AGENT']))
    	{
    	    // if IE 7 or 8
    	    // Write HTML to render tab
    		echo '<a href="' . esc_url( $rum_sst_tab_url ) . '"' . $rum_sst_target_blank . '><div id="rum_sst_tab" class="rum_sst_contents less-ie-9 ' . $rum_sst_left_right_location . '">' . esc_html( $rum_sst_text_for_tab ) . '</div></a>';
    	}
    	else
    	{
    	   // if IE>8
    	   // Write HTML to render tab
    	   echo '<a href="' . esc_url( $rum_sst_tab_url ) . '"' . $rum_sst_target_blank . ' id="rum_sst_tab" class="rum_sst_contents ' . $rum_sst_left_right_location . '">' . esc_html( $rum_sst_text_for_tab ) . '</a>';
    	}
    	}
    
    }

    https://wordpress.org/plugins/simple-side-tab/

  2. srumery
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you for sharing your solution, spearsonit. I didn't test your code above but I wanted to offer a solution that will remove the tab for logged in users just by using CSS.

    .logged-in #rum_sst_tab {display:none;}

    This will turn off the display of the tab for users that are signed in. Unless your site is removing the logged-in class from the body tag, this should work just fine.

    This way, your custom code change in the plugin won't be overwritten by future updates.

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Side Tab
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.