Hide ‘register’ menu when logged in!
-
I want logged in members to not see the ‘register’ page (on menu)
How can I hide certain pages from certain users?
-
We are going to need more information before we can help.
What are you referring to? What menu? In a theme? A widget?
Site url and better description may help
Well this is what I mean:
A user can register and then login. When a user is logged in I want him not to see the ‘register’ option in the menu as he is already registered (and logged in).
Is there a way to make ‘registered’ users not see certain pages?
yep, that’s pretty much what you said the first time.
And then I asked you for a link to your site so that we can help.
I don’t know what menu you are referring to.Is it something in your theme? Is it a widget?
For instance, at the bottom of my theme, I have it set up so that if you are NOT logged in it says
Log In | Register
If you ARE logged in it says
Log Out | Site Admin
Yeah just use the wordpress conditional is_user_logged_in along with a php if statement
For example:
<?php if(is_user_logged_in()){ //Then user is logged in do what you want here for logged in users else{ //User is not logged in do what you want here for non-logged in users } ?>
You can use this logic for the menu item and preventing a page from showing I guess.
Ill try xdesi’s proposal cause that sounds just like what I need ??
site is: https://www.wowgoldadvisor.com
How Can I configure:
if(is_user_logged_in()){ //Then user is logged in do what you want here for logged in users else{ //User is not logged in do what you want here for non-logged in users } ?>
so that in the main menu of my site under ‘User’ It hides ‘Register’ when user is logged in and ‘Profile’ when not logged in?
The menu displays pages.
What’s the code for your top menu then just something like:
wp_list_pages(); ?
wp_list_pages yep
Hm one possible way, replace your wp_list_pages(); with this:
$mypages = wp_list_pages('echo=0'); if(is_user_logged_in()){ $reglink = '<li class="page_item page-item-79"><a href="https://wowgoldadvisor.com/?page_id=79" title="Register">Register</a></li>'; $mypages = str_replace($reglink,'',$mypages); } echo $mypages;
Note: If you had arguments in your wp_list_pages function add them to the end of echo=0 with an amperstand e.g wp_list_pages(‘echo=0&title_li=’)
All the code is doing is removing the register link from the pages if the user is logged in.
I’m sure RVoodoo will know a better way as i’m not too sure on how to manipulate wp_list_pages() to the greatest of effects!
I’m sure RVoodoo will know a better way as i’m not too sure on how to manipulate wp_list_pages() to the greatest of effects!
nono…I was learning from you here!
Unfortunately…I usually scan the forums here to try and help folks from work, while taking breaks. Our internet has filters…and sites like the OPs (anything to do with gaming usually) get blocked….so I can’t look at the site to provide specific feedback
nono…I was learning from you here!
Unfortunately…I usually scan the forums here to try and help folks from work, while taking breaks. Our internet has filters…and sites like the OPs (anything to do with gaming usually) get blocked….so I can’t look at the site to provide specific feedback
Fair enough, my method should do the trick, it’s just that it’s a bit manual, i’m sure there’s a dozen ways to do it as is the case with anything concerning WP!
Unfortunately I’m not to pro at all this ??
I found w-_list_pages in the header.php and thats where i replaced the data.
It didnt work (It completely deleted the menu ?? )
Is that the wrong place or does it not work?
This is what I found
<?php
if (get_option(‘woo_nav’) == ‘true’ )
wp_list_categories(‘sort_column=menu_order&depth=3&title_li=&exclude=’);
else
wp_list_pages(‘sort_column=menu_order&depth=3&title_li=&exclude=’);
?>I selected list by Pages in the admin panel.
How Do I edit that for it to work?
Cheers
Try this: (replace above with this):
<?php if (get_option('woo_nav') == 'true' ) wp_list_categories('sort_column=menu_order&depth=3&title_li=&exclude='); else{ $mypages = wp_list_pages('echo=0&sort_column=menu_order&depth=3&title_li=&exclude='); if(is_user_logged_in()){ $reglink = '<li class="page_item page-item-79"><a href="https://wowgoldadvisor.com/?page_id=79" title="Register">Register</a>'; $mypages = str_replace($reglink,'',$mypages); } echo $mypages; } ?>
Worked!
Could you also hide the ‘login’ link (as they are already logged in :P)
I tried but I didnt manage for it to work :S
Cheers for all your help btw ??
- The topic ‘Hide ‘register’ menu when logged in!’ is closed to new replies.