Page 1 of 1
Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 23rd, 2011, 5:17 pm
by BobTabor
Hi again,
I've created a Welcome page scheme that uses replacement codes. So:
http://members.learnvisualstudio.net/welcome-%%current_user_level%%
Produces:
http://members.learnvisualstudio.net/welcome-0http://members.learnvisualstudio.net/welcome-1etc.
I've envisioned the "welcome" page as the "members' home" page, and want to create a link in navigation to get back to this page. However, having tried to create a custom menu option in WordPress' menu using the replacement code, I see that is not possible.
(1) Can you help me determine what my options are?
(2) Am I thinking of the "welcome" page all wrong? I definitely need to display different info to different users after login, but I also need them to be able to get BACK there.
Thanks!
Bob
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 23rd, 2011, 9:50 pm
by Cristián Lávaque
Well, you can use the constant for the user's level
S2MEMBER_CURRENT_USER_ACCESS_LEVEL.
- Code: Select all
if (is_user_logged_in())
echo '<a href="/welcome-', S2MEMBER_CURRENT_USER_ACCESS_LEVEL, '">Members Home</a>';
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 24th, 2011, 9:45 am
by BobTabor
Ok, that's cool ... but is there no way to get that injected into WordPress' menu? (See image ... I'm trying to get it in there)
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 24th, 2011, 10:48 am
by BobTabor
Ok this is kind of what I'm looking for:
viewtopic.php?f=4&t=10236&p=21366... I would just add to Jason that, if you could, optionally allow to show / hide individual menu options BY MEMBERSHIP LEVEL. In one case, I want to show the appropriate "Home" link in the menu using S2MEMBER_CURRENT_USER_ACCESS_LEVEL (authorized). In another case, I want to show ALL links in the menu based on whether the user is logged in / (authenticated) or not. Thanks!
Any good resources on modifying menus in themes? I'm off to search for that now.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 24th, 2011, 11:10 am
by BobTabor
Solved:
(1) Open up the functions.php file FOR YOUR GIVEN THEME to edit
(2) Add this function at the very bottom (before the closing ?> ):
- Code: Select all
function new_nav_menu_items($items) {
if (is_user_logged_in())
$homelink = '<li><a href="/welcome-' . S2MEMBER_CURRENT_USER_ACCESS_LEVEL.'">Members Home</a></li>';
$items = $homelink . $items;
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
For more information, see:
http://wpfirstaid.com/tag/wp_nav_menu/
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 24th, 2011, 12:46 pm
by Cristián Lávaque
Glad you solved it, Bob. Thanks for sharing the solution.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 3:02 pm
by cassel
This is probably just what i need although i want it conditional to a Custom Capability package.
Would someone be nice enough to point me to what part needs editing for it (i am a little confused with what all those mean):
- navigation tab to hide: forum
- link to that page: mydomain/forum-2
- ccap: forum
Only those who will have purchased one package including "forum" as part of the ccap should see and access that page.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 7:26 pm
by Cristián Lávaque
See the conditional check
is_user_logged_in()? You'd change that to
current_user_can('access_s2member_ccap_forum'). In the next line you edit the link.
I hope that helps.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 7:28 pm
by cassel
Thanks! going to try it now!
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 7:59 pm
by cassel
Almost there (sorry i am dense). I changed the conditional but when you say "In the next line you edit the link", i can do that, however, this line:
$items = $homelink . $items;
In Bob's example, he refers to the home page, is that previous line pointing specifically to the home page? Do i have to change it for another page/tab in the navigation?
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 8:11 pm
by cassel
I am getting an error pointing to this line:
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
Was i supposed to edit it too somehow?
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 8:30 pm
by Cristián Lávaque
By "next line" I meant the very next one after the if condition, the one that starts with $homelink =. The line you quoted is where you concatenate your new nav item to the other ones.
I'm not sure about the error, maybe you want to ask your theme's developer in case his theme works differently for this kind of thing.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
June 26th, 2011, 8:40 pm
by cassel
hum... ok. Checking again.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
September 2nd, 2011, 4:36 pm
by presson
What ended up happening cassel? I have added some of these codes to a data management solution so that if needed I can go back via ediscovery and overlook some of what has gone on in the past. You should contact me and I will share with you just how the process works. Have you ever heard of
StoredIQ? They are an information governance tech group.
Re: Welcome Page, Replacement Codes and WordPress Navigation
Posted:
September 2nd, 2011, 4:58 pm
by cassel
I ended up not using that coding, but instead, redirecting to the page according to the ccaps of the user clicking on it. So now, i have two pages:
- one page that is a sales pitch, with all the selling blahblah, NO breadcrumbs and NO navigation
- one page with the actual links to the class videos, with the breadcrumbs and navigation
If you go to the section in the navigation, you will go here:
http://scrapbookcampus.com/register-bas ... -with-psp/But if you are already registered for that course, it will direct you to this page instead:
http://scrapbookcampus.com/welcome-to-t ... ng-course/It works for me.
Here is the thread that helped me:
viewtopic.php?f=4&t=14376&hilit=redirect