2 types of users

I am building an app with 2 usertypes…regular and business.And each sees a different content once logged in.

The app is built with my own custom code and in order to have a blog in it I installed Wp.

When logged in both users see a link for the blog,

And here is my problem.
As you know in the wp page that comes with the installation there is a sidebar where you can place some links…I want to a link there that will point to the member page for each usertype…which as you can understand is diiferent for each usertype…

But the link must be one…

For example the link for the regular user must lead to regular_member.php…the same applies for the business_user.

What can I do in such a case?

You could register a different custom menu in the functions.php for each user, build the menus in the dashboard, then in sidebar.php use a conditional to call a menu depending on who is logged in.

let’s go step by step…

How am I going to register custom menu for each user?

I found functions.php

Here is the documentation from the WP codex - https://codex.wordpress.org/Function_Reference/register_nav_menus

Let me know if this is sufficient, or if you would like help with it.

Ι used the code snippet(for testing) in the example:

register_nav_menus( array(
'pluginbuddy_mobile' => 'PluginBuddy Mobile Navigation Menu',
'footer_menu' => 'My Custom Footer Menu',

) );

I entered the above in functions.php,but I get

Call to undefined function register_nav_menus()…

What version of WordPress are you using?

4.3.1

You need to make your own function within which you use register_nav_menus(), and then add_action.

Here’s a sample from one of my websites:

function sports_register_menus() {

            register_nav_menus(
                array(
                    'primary-menu' => __( 'Primary Menu' ),
                    'secondary-menu' => __( 'Secondary Menu' ),
                    'footer-menu' => __( 'Footer Menu' )
                )
            );

        }

        add_action( 'init', 'sports_register_menus' );

I get this message:

Call to undefined function add_action()

It is weird though cause in other places of the script…add_action() is being called.

Are you sure you are using the correct functions.php file - the one in your theme, not the one in the core files.

yes…I was using the wrong functions.php…so I registered the menu and created 2 of them…each for every usertype…

Now I am in the stage of writing the conditional in sidebar.php.

And my problem is that I cannot access session contents as to check who is logged in.
var_dump($_SESSION) …gives NULL.

I do not know what rules apply for session access from script to script…I simply cannot access my session variable in sidebar.php

I found a solution to the problem of session access…I will proceed now to write the conditional…if I find a problem again I will inform you.

everything is OK now…thanks for the help.

If there is something I missed I will post again.

Glad I could be of help. :smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.