I need help please finding out how to make an E-commerce website with two different types of logins Some users will submit their products and others can login to purchase. something like Ebay. I heard that wordpress is not the right solution for that, but I really love WP and hope that you can guide me if that is possible here on wordpress? if yes .. What themes/ plugins can be used to acheive that please. Thank you very much in advance.

  • The important part here is that they both use the same login, they just have a flag on their account that indicates if they're a seller or a buyer. It's certainly possible with WordPress, but I sense what you need is much broader in scope – Tom J Nowell Aug 22 '17 at 21:47

Use a single login, and tag each user as either a buyer or a seller using user meta

e.g. lets use a user meta field called shireefs_login_tag

To set the tag:

update_user_meta( $user_id, 'shireefs_login_tag', 'buyer' );

To read the tag:

get_user_meta( $user_id, 'shireefs_login_tag', true );

To redirect on login:

function my_login_redirect( $redirect_to, $request, $user ) {
    if ( !empty( $redirect_to ) {
        return $redirect_to; // dont mess with existing redirects
    //is there a user to check?
    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
        //check for admins
        $login_tag = get_user_meta( $user->ID, 'shireefs_login_tag', true );
        if ( 'buyer' === $login_tag ) {
            return home_url( 'buyers' ); // example.com/buyers
        } else if ( 'seller' === $login_tag ) {
            return home_url( 'sellers' ); // example.com/sellers
        } else {
            return home_url( 'choose' ); // example.com/choose, we dont know if they're a buyer or a seller yet
    } else {
        return $redirect_to;

add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

With this information you now know how to:

  • store if a user is a buyer or a seller
  • retrieve that information so that you can do things with it
  • redirect users to a location based on that info when they log in

Everything else can be built off of those

  • While using meta for this can be ok for very simple cases, using custom Roles and Capabilities is much better and generally the only way to go. – Ihor Vorotnov Aug 22 '17 at 22:36
  • @IhorVorotnov I look forward to your answer – Tom J Nowell Aug 22 '17 at 22:50
  • The exact proper implementation is far beyond the SO answer format and involves many moving parts. I've added a more general answer below. – Ihor Vorotnov Aug 23 '17 at 9:11

While Tom J Nowell's solution will work for pretty simple cases (and definitely will work for the simple case of redirecting users after registration), for more complex things a simple flag in usermeta table will introduce more problems than will solve. Most importantly, you'll need to handle somehow permissions and security.

First, you need to understand that you will need much more than just a simple redirect. Sellers must be able to create and manage custom post type entries (products), see and manage orders of their products etc. Buyers must be able to create and manage their orders. They will have different menus, different actions on items available for them, access to different areas of the site etc. Not to mention lots of transactional emails and other "internal" components. And I'm just scratching the surface here.

Basically, you're introducing two different user roles, and both require more capabilities (permissions) than a default "Subscriber" role (for example, subscribers can't create post type entries, in your case - products). WordPress has a built-in API for Roles and Capabilities. The API itself is on a code level and intended to be used by developers. However, there's a lot of plugins that can help with that, for example, User Role Editor.

I will not dive deeper into the exact implementation as it would take a lot of time and effort and will not fit into the simple SO answer. There are some plugins that can handle at least part of what you need. But if you're going to build a UGC site, you'd better be a developer yourself and spend a lot of time learning all underlying WP APIs, or hire an experienced team that will do it properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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