'Nepal', 'Netherlands', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'North Macedonia', 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palestine, State of', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Pitcairn', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'Romania', 'Russian Federation', 'Rwanda', 'Réunion', 'Saint Barthélemy', 'Saint Helena, Ascension and Tristan da Cunha', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin (French part)', 'Saint Pierre and Miquelon', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Sint Maarten (Dutch part)', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'South Georgia and the South Sandwich Islands', 'South Sudan', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Svalbard and Jan Mayen', 'Sweden', 'Switzerland', 'Syrian Arab Republic', 'Taiwan, Province of China', 'Tajikistan', 'Tanzania, United Republic of', 'Thailand', 'Timor-Leste', 'Togo', 'Tokelau', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu', 'Türkiye', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'United States Minor Outlying Islands', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Venezuela, Bolivarian Republic of', 'Viet Nam', 'Virgin Islands, British', 'Virgin Islands, U.S.', 'Wallis and Futuna', 'Western Sahara', 'Yemen', 'Zambia', 'Zimbabwe', 'Åland Islands'];} private static function val($k){return isset($_POST[$k])?sanitize_text_field(wp_unslash($_POST[$k])):'';} public static function shortcode(){ $message='';$success=false;$ref='';$error_code='';$initial_step=1; if($_SERVER['REQUEST_METHOD']==='POST'&&isset($_POST['bcore_application_submit'])){if(!isset($_POST['bcore_application_nonce'])||!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['bcore_application_nonce'])),'bcore_application'))$message='Your session expired. Please reload and try again.';else{$r=self::submit();if(is_wp_error($r)){$message=$r->get_error_message();$error_code=$r->get_error_code();$initial_step=in_array($error_code,['username','password','password_match'],true)?5:($error_code==='email_exists'||$error_code==='email'?2:($error_code==='declaration'?6:1));}else{$success=true;$ref=$r;$message='Application submitted successfully.';}}} ob_start();echo '
OPEN AN ACCOUNT

Start your banking application

Complete the six steps below. Your account will only become active after staff review and approval.

'; if($message)echo '
'.esc_html($message).($ref?'
Application ID: '.esc_html($ref).'':'').'
'; if($success){echo '

Application received

Your status is Pending Review. We have sent a confirmation to your email address.

Keep your Application ID safe. You can sign in with the credentials you created while your application is being reviewed.

';return ob_get_clean();} echo '
';foreach(['Personal','Address','Account','Identity','Security','Review'] as $i=>$s)echo '';echo '
'; echo '
';wp_nonce_field('bcore_application','bcore_application_nonce'); self::panel(1,'Personal Information','Tell us about yourself.');self::select('title','Title',['Mr'=>'Mr','Mrs'=>'Mrs','Ms'=>'Ms','Dr'=>'Dr','Prof'=>'Prof']);self::input('first_name','First name',true);self::input('middle_name','Middle name');self::input('last_name','Last name',true);self::input('date_of_birth','Date of birth',true,'date');self::select('gender','Gender',['Male'=>'Male','Female'=>'Female','Other'=>'Other','Prefer not to say'=>'Prefer not to say']);self::select('nationality','Nationality',array_combine(self::countries(),self::countries()),true);self::panel_end(); self::panel(2,'Contact & Residential Address','Use your current residential address.');self::input('email','Email address',true,'email');self::input('phone','Phone number',true,'tel');self::select('country','Country of residence',array_combine(self::countries(),self::countries()),true);self::input('state_region','State / Province / Region',true);self::input('city','City / Town',true);self::input('street_address','Street address',true);self::input('building_number','House / Building number');self::input('postal_code','Postal / ZIP code');self::panel_end(); self::panel(3,'Account & Financial Profile','Choose the account you are applying for.');self::select('account_type','Account type',['current'=>'Current Account','checking'=>'Checking Account','savings'=>'Savings Account','business'=>'Business Account','joint'=>'Joint Account','fixed_deposit'=>'Fixed Deposit'],true);self::select('currency','Preferred currency',['USD'=>'USD — US Dollar','EUR'=>'EUR — Euro','GBP'=>'GBP — British Pound'],true);self::select('employment_status','Employment status',['Employed'=>'Employed','Self-employed'=>'Self-employed','Business owner'=>'Business owner','Student'=>'Student','Retired'=>'Retired','Unemployed'=>'Unemployed','Other'=>'Other'],true);self::input('occupation','Occupation / Profession',true);self::input('employer','Employer / Business name');self::select('source_of_funds','Primary source of funds',['Salary'=>'Salary','Business income'=>'Business income','Savings'=>'Savings','Investments'=>'Investments','Pension'=>'Pension','Family support'=>'Family support','Other'=>'Other'],true);self::select('annual_income','Approximate annual income',['Under 25,000'=>'Under 25,000','25,000–49,999'=>'25,000–49,999','50,000–99,999'=>'50,000–99,999','100,000–249,999'=>'100,000–249,999','250,000+'=>'250,000+'],true);self::panel_end(); self::panel(4,'Identity Verification','Upload clear documents. Files are restricted to PDF/JPG/PNG, maximum 5 MB each.');self::select('identity_type','Identity document',['Passport'=>'Passport','National ID'=>'National ID','Driver License'=>'Driver License','Residence Permit'=>'Residence Permit'],true);self::input('identity_number','Identity document number',true);self::file('identity_document','Identity document',true);self::file('proof_of_address','Proof of address',true);self::panel_end(); self::panel(5,'Security Setup','Create the credentials you will use to sign in.');self::input('username','Username',true);self::input('password','Password',true,'password');self::input('password_confirm','Confirm password',true,'password');echo '
Use at least 10 characters. Choose a strong password that you will use to securely access your account.
';self::panel_end(); self::panel(6,'Review & Submit','Review your information before submitting.');echo '
';self::panel_end(); echo '

';return ob_get_clean(); } private static function panel($n,$t,$p){echo '
STEP '.$n.' OF 6

'.esc_html($t).'

'.esc_html($p).'

';} private static function panel_end(){echo '
';} private static function input($n,$l,$req=false,$type='text'){echo '
';} private static function select($n,$l,$opts,$req=false){$v=self::val($n);echo '
';} private static function file($n,$l,$req=false){echo '
';} private static function upload_doc($field,$app_id,$type){if(empty($_FILES[$field]['name']))return new WP_Error('doc','Please upload all required documents.');$f=$_FILES[$field];if($f['error']!==UPLOAD_ERR_OK)return new WP_Error('doc','A document upload failed. Please try again.');if($f['size']>5*1024*1024)return new WP_Error('doc','Each document must be 5 MB or smaller.');$allowed=['application/pdf'=>'pdf','image/jpeg'=>'jpg','image/png'=>'png'];$check=wp_check_filetype_and_ext($f['tmp_name'],$f['name']);if(empty($check['type'])||!isset($allowed[$check['type']]))return new WP_Error('doc','Only PDF, JPG and PNG documents are allowed.');$up=wp_upload_dir();$dir=trailingslashit($up['basedir']).'bcore-private';if(!wp_mkdir_p($dir))return new WP_Error('doc','Secure upload directory could not be created.');if(!file_exists($dir.'/.htaccess'))@file_put_contents($dir.'/.htaccess',"Deny from all\n");$name=wp_generate_password(24,false,false).'.'.$allowed[$check['type']];$dest=trailingslashit($dir).$name;if(!@move_uploaded_file($f['tmp_name'],$dest))return new WP_Error('doc','Could not store the uploaded document.');global $wpdb;$wpdb->insert(BCore_DB::table('application_documents'),['application_id'=>$app_id,'document_type'=>$type,'original_name'=>sanitize_file_name($f['name']),'stored_path'=>$dest,'mime_type'=>$check['type'],'uploaded_at'=>BCore_Utils::now()]);return true;} private static function submit(){global $wpdb;$required=['first_name','last_name','date_of_birth','nationality','email','phone','country','state_region','city','street_address','account_type','currency','employment_status','occupation','source_of_funds','annual_income','identity_type','identity_number','username','password','password_confirm'];foreach($required as $f)if(self::val($f)==='')return new WP_Error('required','Please complete all required fields.');if(empty($_POST['declaration']))return new WP_Error('declaration','Please confirm the declaration.');$email=sanitize_email(wp_unslash($_POST['email']));if(!is_email($email))return new WP_Error('email','Please enter a valid email address.');$username=sanitize_user(wp_unslash($_POST['username']),true);if(strlen($username)<4)return new WP_Error('username','Please choose a username with at least 4 characters.');if(username_exists($username))return new WP_Error('username','That username is already in use.');if(email_exists($email))return new WP_Error('email_exists','That email address already has an account. Please sign in or use another email.');$pass=(string)wp_unslash($_POST['password']);if(strlen($pass)<10)return new WP_Error('password','Password must be at least 10 characters.');if(!hash_equals($pass,(string)wp_unslash($_POST['password_confirm'])))return new WP_Error('password_match','Passwords do not match.');$type=sanitize_key(self::val('account_type'));$currency=strtoupper(self::val('currency'));if(!in_array($type,BCore_Utils::account_types(),true)||!in_array($currency,BCore_Utils::currencies(),true))return new WP_Error('account','Invalid account selection.');$uid=wp_create_user($username,$pass,$email);if(is_wp_error($uid))return $uid;$user=new WP_User($uid);$user->set_role('bank_applicant');wp_update_user(['ID'=>$uid,'first_name'=>self::val('first_name'),'last_name'=>self::val('last_name'),'display_name'=>trim(self::val('first_name').' '.self::val('last_name'))]);$ref=BCore_Utils::ref('APP');$data=['application_ref'=>$ref,'wp_user_id'=>$uid,'title'=>self::val('title'),'first_name'=>self::val('first_name'),'middle_name'=>self::val('middle_name'),'last_name'=>self::val('last_name'),'email'=>$email,'phone'=>self::val('phone'),'date_of_birth'=>self::val('date_of_birth'),'gender'=>self::val('gender'),'nationality'=>self::val('nationality'),'country'=>self::val('country'),'state_region'=>self::val('state_region'),'city'=>self::val('city'),'street_address'=>self::val('street_address'),'building_number'=>self::val('building_number'),'postal_code'=>self::val('postal_code'),'occupation'=>self::val('occupation'),'employer'=>self::val('employer'),'employment_status'=>self::val('employment_status'),'source_of_funds'=>self::val('source_of_funds'),'annual_income'=>self::val('annual_income'),'account_type'=>$type,'currency'=>$currency,'identity_type'=>self::val('identity_type'),'identity_number'=>self::val('identity_number'),'status'=>'pending','submitted_at'=>BCore_Utils::now()];$applications_table=BCore_DB::table('applications');$columns=$wpdb->get_col("SHOW COLUMNS FROM `{$applications_table}`",0);if(is_array($columns)&&$columns){$data=array_intersect_key($data,array_flip($columns));}if(!$wpdb->insert($applications_table,$data)){if(!function_exists('wp_delete_user'))require_once ABSPATH.'wp-admin/includes/user.php';wp_delete_user($uid);return new WP_Error('save','We could not save your application.');}$id=$wpdb->insert_id;foreach([['identity_document','identity'],['proof_of_address','address']] as $d){$r=self::upload_doc($d[0],$id,$d[1]);if(is_wp_error($r)){return $r;}}BCore_Audit::log('application_submitted','application',$id,['reference'=>$ref]);wp_mail($email,'Bank account application received',"We received your application.\n\nApplication ID: $ref\nStatus: Pending Review\n\nWe will email you when the status changes.");return $ref;} public static function status_shortcode(){if(!is_user_logged_in())return '

Please sign in to view your application status.

';global $wpdb;$a=$wpdb->get_row($wpdb->prepare('SELECT * FROM '.BCore_DB::table('applications').' WHERE wp_user_id=%d ORDER BY id DESC LIMIT 1',get_current_user_id()));if(!$a)return '

No application was found for this account.

';$steps=['pending'=>'Under Review','more_info'=>'More Information Required','approved'=>'Approved','rejected'=>'Not Approved'];$label=$steps[$a->status]??ucwords(str_replace('_',' ',$a->status));return '
APPLICATION STATUS

'.esc_html($label).'

Application ID: '.esc_html($a->application_ref).'

'.($a->customer_message?'
'.nl2br(esc_html($a->customer_message)).'
':'').'
Submitted ✓VerificationUnder ReviewApprovedAccount Active
';}