Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active September 11, 2017 18:50
Show Gist options
  • Save amdrew/7477544 to your computer and use it in GitHub Desktop.
Save amdrew/7477544 to your computer and use it in GitHub Desktop.
Allows you to search by the payment ID on the downloads > payment history screen. Also allows you to search on the downloads page if you know the ID.
<?php
function edd_search_by_id( $where ) {
if( is_admin() ) {
global $wpdb, $pagenow, $typenow;
if ( ! ( 'download' == $typenow && in_array( $pagenow, array( 'edit.php' ) ) ) )
return $where;
if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) && intval( $_GET['s'] ) != 0 ) {
$where .= ' or ' . $wpdb->posts . '.ID = ' . $_GET['s'];
}
}
return $where;
}
add_filter( 'posts_where', 'edd_search_by_id' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment