Shortcodes & Widgets

KiviCare Register/Login Shortcode

Overview

The KCRegisterLogin shortcode provides a unified Login & Registration interface for the KiviCare Clinic Management System.
It supports multiple user roles, Google reCAPTCHA v3, clinic selection, and flexible form customization through shortcode attributes.

Shortcode Tag:

[kivicareRegisterLogin]

Shortcode Attributes

initial_tab

  • Type: String
  • Default: '' (empty)
  • Allowed Values: login, register, or empty
  • Description:
    • login → Displays only the login form
    • register → Displays only the registration form
    • Empty → Shows login by default with tab switching enabled
  • Example:[kivicareRegisterLogin initial_tab="register"]

redirect_url

  • Type: String
  • Default: '' (empty)
  • Description:
    Redirects the user after a successful login.
    If not provided, the system uses the default redirect or the current page.
  • Example:[kivicareRegisterLogin redirect_url="https://example.com/dashboard"]

login_text

  • Type: String
  • Default: '' (empty)
  • Description:
    Custom label for the Login tab. Uses default text if empty.
  • Example:[kivicareRegisterLogin login_text="Sign In"]

register_text

  • Type: String
  • Default: '' (empty)
  • Description:
    Custom label for the Register tab. Uses default text if empty.
  • Example:[kivicareRegisterLogin register_text="Create Account"]

patient_role_only

  • Type: String
  • Default: yes
  • Allowed Values: yes, no
  • Description:
    • yes → Only Patient role is available
    • no → Roles are loaded from plugin settings or userroles attribute
  • Example:[kivicareRegisterLogin patient_role_only="no"]

clinic_id

  • Type: Integer
  • Default: '' (empty)
  • Description:
    Pre-selects a specific clinic in the registration form.
  • Example:[kivicareRegisterLogin clinic_id="5"]

userroles

  • Type: String (comma-separated)
  • Default: '' (empty)
  • Allowed Roles: patient, doctor, receptionist
  • Description:
    Limits available registration roles.
    Overrides patient_role_only when provided.
  • Example:[kivicareRegisterLogin userroles="patient,doctor"]

Usage Examples

Basic Login & Registration (Patient Only)

[kivicareRegisterLogin]

Registration Form Only (Multiple Roles)

[kivicareRegisterLogin initial_tab="register" patient_role_only="no" userroles="patient,doctor"]

Login Form Only with Custom Text

[kivicareRegisterLogin initial_tab="login" login_text="Sign In"]

Pre-selected Clinic with Redirect

[kivicareRegisterLogin clinic_id="3" redirect_url="https://example.com/patient-dashboard"]

Doctor Registration Only

[kivicareRegisterLogin initial_tab="register" userroles="doctor"]

Features

1. Dual Tab Interface

  • Login and Registration in separate tabs
  • Single-form mode when initial_tab is set
  • Smooth tab switching with message reset

2. User Role Management

  • Supports Patient, Doctor, Receptionist
  • Role visibility controlled by:
    • Plugin settings
    • patient_role_only
    • userroles attribute

3. Google reCAPTCHA v3 Integration

  • Automatically loads reCAPTCHA when enabled
  • Token generation for login and registration
  • Admin notice when reCAPTCHA is disabled
  • Configurable from plugin settings

4. Clinic Selection

  • Fetches active clinics only
  • Supports pre-selection via clinic_id
  • Integrated with frontend registration flow

5. Form Customization

  • Custom tab labels
  • Smart quote normalization
  • Fully sanitized and escaped output

6. User Experience Enhancements

  • Logged-in user detection with logout option
  • Loading indicators
  • Error & success messages
  • International phone number validation
  • Password visibility toggle
  • Optional gender field

7. Security Features

  • WordPress nonce verification
  • Input sanitization
  • Output escaping
  • reCAPTCHA protection
  • Secure REST API usage

Suggestions & Improvements

Your email address will not be published. Required fields are marked *