Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Created June 19, 2025 07:35
Show Gist options
  • Save finalwebsites/cfa29890cc47afee6ee754194e4759b4 to your computer and use it in GitHub Desktop.
Save finalwebsites/cfa29890cc47afee6ee754194e4759b4 to your computer and use it in GitHub Desktop.
Use two WCAPF forms based on the chosen language
<?php
protected function retrieve_form() {
global $wcapf_form;
if ( ! $wcapf_form ) {
return array();
}
$desired_form = array();
$taal = pll_current_language();
foreach ( $wcapf_form as $form ) {
if ( empty( $form['rendered'] ) ) {
if ($taal == 'en') {
if ($form['form_title'] == 'English') {
$desired_form = $form;
break;
}
} elseif ($taal == 'nl') {
if ($form['form_title'] == 'Nederlands') {
$desired_form = $form;
break;
}
} else {
$desired_form = $form;
break;
}
}
}
return $desired_form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment