Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matty0501/4d59767391df4eff18c21baba437d321 to your computer and use it in GitHub Desktop.
Save matty0501/4d59767391df4eff18c21baba437d321 to your computer and use it in GitHub Desktop.
gpeb-navigation-with-filtered-choices.php
<?php
// helper method
function get_array_subset( $array, $offset, $limit ) {
if ( $offset > count( $array ) - 1) {
return [];
}
$start = $offset;
$length = min( $limit, count( $array ) - $offset );
return array_slice( $array, $start, $length );
}
add_filter( 'gpeb_queryer_entries', function( $entries, $gf_queryer ) {
$form_id = $gf_queryer->form_id;
$filtered_entries = array_filter( GFAPI::get_entries( $form_id ), function( $entry ) {
// Enter your array_filter function code here
});
$offset = rgget( 'offset' ) ? rgget( 'offset' ) : 0;
$limit = $gf_queryer->block_context['gp-entry-blocks/limit'];
$gf_queryer->entries = get_array_subset( $filtered_entries, $offset, $limit );
$gf_queryer->total_count = count( $filtered_entries );
return $gf_queryer->entries;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment