WooCommerce Login Integration

🟡 Intermediate
⏱️ 20 minutes
Free & Pro

Summary

Connect Attributes User Access authentication with WooCommerce to provide custom login pages, enhanced security features, and unified customer account management. This guide covers My Account integration, checkout customization, and seamless authentication flow.

Prerequisites

  • ✅ Attributes User Access plugin installed (Free or Pro)
  • ✅ WooCommerce 5.0+ installed and activated
  • ✅ Custom login page created
  • ✅ Basic WordPress and WooCommerce knowledge

Step 1: Enable WooCommerce Integration

  1. Navigate to Users → Attributes User Access → Settings
  2. Click on Integrations tab
  3. Find WooCommerce Integration section
  4. Enable “Integrate with WooCommerce”
  5. Configure integration options:
    • ☑️ Replace WooCommerce login forms
    • ☑️ Redirect to custom login after logout
    • ☑️ Show custom login on My Account page
    • ☑️ Enable custom registration for customers
  6. Save settings

Step 2: Configure My Account Page

Customize WooCommerce My Account page to use your custom login:

Replace Default Login Form

  1. Go to WooCommerce → Settings → Accounts & Privacy
  2. Note the My Account page (usually /my-account/)
  3. In Attributes settings, set WooCommerce Login Page to your custom login page
  4. The plugin automatically redirects WooCommerce login forms to your custom page

Customize Redirect Behavior

Action Default Redirect Custom Option
After Login My Account Dashboard Custom page (orders, shop, etc.)
After Logout Homepage Custom login page
After Registration My Account Welcome page or shop
Checkout (Not logged in) Standard WC login Custom login page

Step 3: Customize Checkout Authentication

Control how authentication works during checkout:

Checkout Login Options

  • Guest Checkout – Allow purchases without account
    // WooCommerce → Settings → Accounts & Privacy
    ☑️ Allow customers to place orders without an account

  • Required Login – Force login before checkout
  • Optional Registration – Create account during checkout

Checkout Page Login Form

Add custom login to checkout page:

// Option 1: Use WooCommerce settings
WooCommerce → Settings → Accounts & Privacy
☑️ Allow customers to log in at checkout

// Option 2: Add shortcode to checkout page
[attrua_login_form redirect_to="/checkout"]

Step 4: Customer Registration Integration

Sync custom registration forms with WooCommerce customer accounts:

Enable Customer Registration

  1. Create custom registration form (see Registration Forms article)
  2. Add WooCommerce-specific fields:
    • Billing address fields
    • Shipping address fields
    • Company information
    • Phone number
  3. Map fields to WooCommerce customer meta:
    // Auto-map custom fields to WooCommerce
    add_filter('attrua_woocommerce_customer_meta', function($meta, $user_id) {
        $meta['billing_first_name'] = get_user_meta($user_id, 'first_name', true);
        $meta['billing_last_name'] = get_user_meta($user_id, 'last_name', true);
        $meta['billing_phone'] = get_user_meta($user_id, 'phone', true);
        $meta['billing_company'] = get_user_meta($user_id, 'company', true);
        return $meta;
    }, 10, 2);
    

Step 5: Sync User Roles with Customer Roles

Manage WordPress user roles alongside WooCommerce customer status:

Role Mapping Configuration

WordPress Role WooCommerce Status Use Case
Customer Standard Customer Regular shoppers
Subscriber Newsletter only Email list without purchases
Custom: VIP Member Premium Customer Loyalty program, discounts
Custom: Wholesale B2B Customer Wholesale pricing access

Step 6: Add Login to Cart Page

Allow customers to log in before viewing cart:

// Add login prompt to cart page for non-logged-in users
add_action('woocommerce_before_cart', function() {
    if (!is_user_logged_in()) {
        echo '
'; echo 'Have an account? Log in '; echo 'to see your saved cart items and faster checkout.'; echo '
'; } }); // Or use shortcode in cart page template [attrua_login_form message="Log in to access your saved cart"]

Step 7: Customize WooCommerce Email Templates

Match email notifications with your authentication branding:

Email Template Integration

  • Use custom login URL in WooCommerce emails
  • Add password reset link with custom styling
  • Include account management instructions
// Customize login URL in WooCommerce emails
add_filter('woocommerce_email_footer_text', function($footer_text) {
    $login_url = get_permalink(get_option('attrua_login_page_id'));
    return str_replace(
        wp_login_url(),
        $login_url,
        $footer_text
    );
});

Step 8: Test Integration

Verify all integration points work correctly:

Testing Checklist

  • ☑️ Custom login appears on My Account page
  • ☑️ Login redirect works correctly after authentication
  • ☑️ Logout redirects to custom login page
  • ☑️ Guest checkout works (if enabled)
  • ☑️ Customer registration creates WooCommerce customer
  • ☑️ Billing/shipping data saves correctly
  • ☑️ Cart persists after login
  • ☑️ Wishlist/favorites accessible after login
  • ☑️ Order history displays in My Account
  • ☑️ Email templates use custom login URL

Advanced Customization

Custom My Account Dashboard

Add custom content to My Account dashboard:

// Add welcome message with user name
add_action('woocommerce_account_dashboard', function() {
    $user = wp_get_current_user();
    echo '
'; echo '

Welcome back, ' . esc_html($user->display_name) . '!

'; echo '

Manage your orders, addresses, and account settings.

'; echo '
'; }, 5);

Conditional Content Based on Login Status

// Show different pricing for logged-in users
add_filter('woocommerce_get_price_html', function($price, $product) {
    if (is_user_logged_in()) {
        // Show member pricing
        $member_price = get_post_meta($product->get_id(), '_member_price', true);
        if ($member_price) {
            return wc_price($member_price) . ' Member Price';
        }
    }
    return $price;
}, 10, 2);

Troubleshooting

❌ Login Form Not Appearing on My Account

  • Verify WooCommerce integration is enabled in settings
  • Clear WooCommerce transients and cache
  • Check for template overrides in theme
  • Test with default WordPress theme

❌ Redirect Loop After Login

  • Check redirect URL settings in both plugins
  • Disable other redirect plugins temporarily
  • Verify My Account page is published
  • Clear browser cookies and cache

❌ Customer Data Not Syncing

  • Verify field mapping in integration settings
  • Check WooCommerce customer role assignment
  • Test with manual user creation
  • Review error logs for sync issues

Need Help?

Contact our support team for WooCommerce integration assistance:

Review My Order

0

Subtotal