{"id":2822,"date":"2026-07-08T10:25:59","date_gmt":"2026-07-08T10:25:59","guid":{"rendered":"https:\/\/worldsafety.co.za\/?page_id=2822"},"modified":"2026-07-08T10:30:19","modified_gmt":"2026-07-08T10:30:19","slug":"test","status":"publish","type":"page","link":"https:\/\/worldsafety.co.za\/index.php\/test\/","title":{"rendered":"Test"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"2822\" class=\"elementor elementor-2822\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d23fbb5 e-flex e-con-boxed e-con e-parent\" data-id=\"d23fbb5\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e812d1a elementor-widget elementor-widget-html\" data-id=\"e812d1a\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\r\nif (!defined('ABSPATH')) {\r\n    exit;\r\n}\r\n\r\n\/**\r\n * Replace these five links with the correct registration links.\r\n *\/\r\nfunction safety_router_get_redirect_links() {\r\n    return [\r\n        'HIC' => 'PASTE_HIC_REGISTRATION_LINK_HERE',\r\n        'MIC' => 'PASTE_MIC_REGISTRATION_LINK_HERE',\r\n        'AFRO_LIC' => 'PASTE_AFRO_REGION_LIC_REGISTRATION_LINK_HERE',\r\n        'HIC_MIC_STUDENT' => 'PASTE_HIC_MIC_STUDENT_LINK_HERE',\r\n        'AFRO_LIC_STUDENT' => 'PASTE_AFRO_LIC_STUDENT_LINK_HERE',\r\n    ];\r\n}\r\n\r\n\/**\r\n * Create table to save details.\r\n *\/\r\nfunction safety_router_create_table() {\r\n    global $wpdb;\r\n\r\n    $table_name = $wpdb->prefix . 'safety_registration_leads';\r\n    $charset_collate = $wpdb->get_charset_collate();\r\n\r\n    require_once ABSPATH . 'wp-admin\/includes\/upgrade.php';\r\n\r\n    $sql = \"CREATE TABLE {$table_name} (\r\n        id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n        first_name VARCHAR(120) NOT NULL,\r\n        last_name VARCHAR(120) NOT NULL,\r\n        email VARCHAR(190) NOT NULL,\r\n        country VARCHAR(160) NOT NULL,\r\n        is_student TINYINT(1) NOT NULL DEFAULT 0,\r\n        detected_category VARCHAR(100) NOT NULL,\r\n        redirect_url TEXT NOT NULL,\r\n        user_ip VARCHAR(45) NULL,\r\n        user_agent TEXT NULL,\r\n        created_at DATETIME NOT NULL,\r\n        PRIMARY KEY (id),\r\n        KEY email (email),\r\n        KEY detected_category (detected_category),\r\n        KEY created_at (created_at)\r\n    ) {$charset_collate};\";\r\n\r\n    dbDelta($sql);\r\n}\r\n\r\nadd_action('init', 'safety_router_create_table');\r\n\r\n\/**\r\n * Countries that must go to AFRO Region and LIC registration.\r\n *\/\r\nfunction safety_router_get_afro_countries() {\r\n    return [\r\n        'South Africa',\r\n        'Zimbabwe',\r\n        'Zambia',\r\n        'Botswana',\r\n        'Namibia',\r\n        'Mozambique',\r\n        'Lesotho',\r\n        'Eswatini',\r\n        'Kenya',\r\n        'Nigeria',\r\n        'Ghana',\r\n        'Uganda',\r\n        'Rwanda',\r\n        'Malawi',\r\n        'Tanzania',\r\n        'Ethiopia',\r\n        'Somalia',\r\n        'Sudan',\r\n        'South Sudan',\r\n        'Morocco',\r\n        'Egypt, Arab Rep.',\r\n        'Algeria',\r\n        'Tunisia',\r\n        'Angola',\r\n        'Benin',\r\n        'Burkina Faso',\r\n        'Burundi',\r\n        'Cameroon',\r\n        'Central African Republic',\r\n        'Chad',\r\n        'Comoros',\r\n        'Congo, Dem. Rep.',\r\n        'Congo, Rep.',\r\n        'C\u00f4te d\\'Ivoire',\r\n        'Djibouti',\r\n        'Eritrea',\r\n        'Gabon',\r\n        'Gambia, The',\r\n        'Guinea',\r\n        'Guinea-Bissau',\r\n        'Liberia',\r\n        'Libya',\r\n        'Madagascar',\r\n        'Mali',\r\n        'Mauritania',\r\n        'Mauritius',\r\n        'Niger',\r\n        'Senegal',\r\n        'Seychelles',\r\n        'Sierra Leone',\r\n        'Togo',\r\n    ];\r\n}\r\n\r\n\/**\r\n * Low-income countries.\r\n *\/\r\nfunction safety_router_get_lic_countries() {\r\n    return [\r\n        'Afghanistan',\r\n        'Burkina Faso',\r\n        'Burundi',\r\n        'Central African Republic',\r\n        'Chad',\r\n        'Congo, Dem. Rep.',\r\n        'Eritrea',\r\n        'Ethiopia',\r\n        'Gambia, The',\r\n        'Guinea-Bissau',\r\n        'Liberia',\r\n        'Madagascar',\r\n        'Malawi',\r\n        'Mali',\r\n        'Mozambique',\r\n        'Niger',\r\n        'Rwanda',\r\n        'Sierra Leone',\r\n        'Somalia',\r\n        'South Sudan',\r\n        'Sudan',\r\n        'Uganda',\r\n        'Yemen, Rep.',\r\n    ];\r\n}\r\n\r\n\/**\r\n * High-income countries.\r\n *\/\r\nfunction safety_router_get_hic_countries() {\r\n    return [\r\n        'United States',\r\n        'United Kingdom',\r\n        'Canada',\r\n        'Australia',\r\n        'Germany',\r\n        'France',\r\n        'Netherlands',\r\n        'Switzerland',\r\n        'Sweden',\r\n        'Norway',\r\n        'Japan',\r\n        'Austria',\r\n        'Belgium',\r\n        'Denmark',\r\n        'Finland',\r\n        'Ireland',\r\n        'Italy',\r\n        'New Zealand',\r\n        'Portugal',\r\n        'Spain',\r\n        'United Arab Emirates',\r\n        'Qatar',\r\n        'Saudi Arabia',\r\n        'Singapore',\r\n        'Korea, Rep.',\r\n    ];\r\n}\r\n\r\n\/**\r\n * Work out registration category.\r\n *\/\r\nfunction safety_router_detect_category($country, $is_student) {\r\n    $afro_countries = safety_router_get_afro_countries();\r\n    $lic_countries = safety_router_get_lic_countries();\r\n    $hic_countries = safety_router_get_hic_countries();\r\n\r\n    $is_afro = in_array($country, $afro_countries, true);\r\n    $is_lic = in_array($country, $lic_countries, true);\r\n    $is_hic = in_array($country, $hic_countries, true);\r\n\r\n    if ($is_afro || $is_lic) {\r\n        return $is_student ? 'AFRO_LIC_STUDENT' : 'AFRO_LIC';\r\n    }\r\n\r\n    if ($is_student) {\r\n        return 'HIC_MIC_STUDENT';\r\n    }\r\n\r\n    if ($is_hic) {\r\n        return 'HIC';\r\n    }\r\n\r\n    return 'MIC';\r\n}\r\n\r\nfunction safety_router_category_label($category) {\r\n    $labels = [\r\n        'HIC' => 'HIC Registration',\r\n        'MIC' => 'MIC Registration',\r\n        'AFRO_LIC' => 'AFRO Region & LIC Registration',\r\n        'HIC_MIC_STUDENT' => 'HIC & MIC Student',\r\n        'AFRO_LIC_STUDENT' => 'Afro & LIC Students',\r\n    ];\r\n\r\n    return $labels[$category] ?? 'Unknown';\r\n}\r\n\r\n\/**\r\n * Save details, then redirect.\r\n *\/\r\nfunction safety_router_save_and_redirect() {\r\n    global $wpdb;\r\n\r\n    safety_router_create_table();\r\n\r\n    $first_name = sanitize_text_field(wp_unslash($_POST['first_name'] ?? ''));\r\n    $last_name = sanitize_text_field(wp_unslash($_POST['last_name'] ?? ''));\r\n    $email = sanitize_email(wp_unslash($_POST['email'] ?? ''));\r\n    $country = sanitize_text_field(wp_unslash($_POST['country'] ?? ''));\r\n    $is_student = sanitize_text_field(wp_unslash($_POST['is_student'] ?? '')) === '1' ? 1 : 0;\r\n\r\n    if ($first_name === '' || $last_name === '' || $email === '' || $country === '') {\r\n        wp_die('Please complete all required fields.');\r\n    }\r\n\r\n    if (!is_email($email)) {\r\n        wp_die('Please enter a valid email address.');\r\n    }\r\n\r\n    $category = safety_router_detect_category($country, $is_student);\r\n    $links = safety_router_get_redirect_links();\r\n\r\n    $redirect_url = $links[$category] ?? '';\r\n\r\n    if ($redirect_url === '' || strpos($redirect_url, 'PASTE_') !== false) {\r\n        wp_die('Redirect link is not configured. Please update the registration links in the PHP code.');\r\n    }\r\n\r\n    $table_name = $wpdb->prefix . 'safety_registration_leads';\r\n\r\n    $saved = $wpdb->insert(\r\n        $table_name,\r\n        [\r\n            'first_name' => $first_name,\r\n            'last_name' => $last_name,\r\n            'email' => $email,\r\n            'country' => $country,\r\n            'is_student' => $is_student,\r\n            'detected_category' => safety_router_category_label($category),\r\n            'redirect_url' => esc_url_raw($redirect_url),\r\n            'user_ip' => sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'] ?? '')),\r\n            'user_agent' => sanitize_textarea_field(wp_unslash($_SERVER['HTTP_USER_AGENT'] ?? '')),\r\n            'created_at' => current_time('mysql'),\r\n        ],\r\n        [\r\n            '%s',\r\n            '%s',\r\n            '%s',\r\n            '%s',\r\n            '%d',\r\n            '%s',\r\n            '%s',\r\n            '%s',\r\n            '%s',\r\n            '%s',\r\n        ]\r\n    );\r\n\r\n    if (!$saved) {\r\n        wp_die('Details could not be saved. Please try again.');\r\n    }\r\n\r\n    wp_redirect(esc_url_raw($redirect_url));\r\n    exit;\r\n}\r\n\r\nadd_action('admin_post_safety_registration_router_html_save', 'safety_router_save_and_redirect');\r\nadd_action('admin_post_nopriv_safety_registration_router_html_save', 'safety_router_save_and_redirect');\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>if (!defined(&#8216;ABSPATH&#8217;)) { exit; } \/** * Replace these five links with the correct registration links. *\/ function safety_router_get_redirect_links() { return [ &#8216;HIC&#8217; => &#8216;PASTE_HIC_REGISTRATION_LINK_HERE&#8217;, &#8216;MIC&#8217; => &#8216;PASTE_MIC_REGISTRATION_LINK_HERE&#8217;, &#8216;AFRO_LIC&#8217; => &#8216;PASTE_AFRO_REGION_LIC_REGISTRATION_LINK_HERE&#8217;, &#8216;HIC_MIC_STUDENT&#8217; => &#8216;PASTE_HIC_MIC_STUDENT_LINK_HERE&#8217;, &#8216;AFRO_LIC_STUDENT&#8217; => &#8216;PASTE_AFRO_LIC_STUDENT_LINK_HERE&#8217;, ]; } \/** * Create table to save details. *\/ function safety_router_create_table() { global $wpdb; $table_name = $wpdb->prefix [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-2822","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/pages\/2822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/comments?post=2822"}],"version-history":[{"count":7,"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/pages\/2822\/revisions"}],"predecessor-version":[{"id":2838,"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/pages\/2822\/revisions\/2838"}],"wp:attachment":[{"href":"https:\/\/worldsafety.co.za\/index.php\/wp-json\/wp\/v2\/media?parent=2822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}