0

I intend to use Wordpress for the proof-of-concept of a cloud-based SaaS application I am building. My research into multi-tenancy and Wordpress only sheds insight into multiple sites sharing the same back-end, however, I would like to have a single site but the admin section should have different user roles that can only access their relevant content and dashboard to manage and or make requests to certain data. The dashboard will be different for 3 user roles so they can achieve they desired functions effectively.

Is it in any way possible for me to create new user role and assign the aforementioned rights to the specific rights (e.g. supplier, agent, tour operator)?

1
  • Take a look at the role manager plugin and similar in the repo. So far this is just a plugin recommendation? If so, it's off topic.
    – kaiser
    Commented Jan 16, 2013 at 16:02

1 Answer 1

0

You'll need to combine some plugins and a couple of hooks.

Apart from the role management, I'd recommend Adminimize: it's quite powerful to clean up the dashboard based on user roles.

And then:

/** 
 * When a registered user tries to visit a page for which he doesn't have access,
 * i.e.: http:/example.com/wp-admin/plugins.php,
 * WordPress displays a standard WP error message.
 * This will redirect instead of displaying the message:
 * "You do not have sufficient permissions to access this page."
 */
add_action( 'admin_page_access_denied', 'access_denied_wpse_57206' );

function access_denied_wpse_57206()
{
    wp_redirect( home_url() );
    exit();
}

/**
 * Redirect users of an specific role, if they try to access a URL
 * of an admin page that they would have capability to do
 * i.e.: http:/example.com/wp-admin/tools.php
 */
add_action( 'admin_init', 'admin_init_wpse_81841' );

function admin_init_wpse_81841()
{
    global $current_user, $pagenow;
    get_currentuserinfo();
    if ( 'tools.php' == $pagenow && user_can( $current_user, 'editor' ) ) 
    {
        wp_redirect( admin_url( 'index.php' ) );
        exit();
    }
    // Add as many conditions as necessary
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.