Skip to content

Instantly share code, notes, and snippets.

@pbearne
Last active November 9, 2023 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pbearne/16d4462762f96318d1f2082d3b79ad44 to your computer and use it in GitHub Desktop.
Save pbearne/16d4462762f96318d1f2082d3b79ad44 to your computer and use it in GitHub Desktop.
re-order matador application form
add_filter( 'matador_application_form_args', function( $args ) {
$args['fields'] = matador_jobs_moveElementInArray( $args['fields'], 'mobile', array_search('phone', array_keys( $fields ) ) + 1 );
return $args;
}, 99 );
function matador_jobs_moveElementInArray($array, $toMove, $targetIndex) {
if (is_int($toMove)) {
$tmp = array_splice($array, $toMove, 1);
array_splice($array, $targetIndex, 0, $tmp);
$output = $array;
}
elseif (is_string($toMove)) {
$indexToMove = array_search($toMove, array_keys($array));
$itemToMove = $array[$toMove];
array_splice($array, $indexToMove, 1);
$i = 0;
$output = Array();
foreach($array as $key => $item) {
if ($i == $targetIndex) {
$output[$toMove] = $itemToMove;
}
$output[$key] = $item;
$i++;
}
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment