Hello Kai,
You can restrict showing packages from user in package list dropdown by using following code snippet.
/* Restrict package during upgrade */
function _gd_custom_restrict_upgrade_package_query( $sql ) {
global $post, $wpdb;
if ( empty( $_REQUEST['pid'] ) || empty( $_REQUEST['package_id'] ) ) {
return $sql;
}
if ( is_admin() || ! ( ! empty( $post ) && $post->ID == $_REQUEST['pid'] ) ) {
return $sql;
}
if ( ! geodir_is_page( 'add-listing' ) ) {
return $sql;
}
$package_id = geodir_get_post_meta( absint( $_REQUEST['pid'] ), 'package_id', true );
$restrict_packages = array();
// DO STUFF HERE
if ( $package_id == 12 ) {
$restrict_packages = array( 1, 2, 3, 4 );
}
/* // Example
if ( $package_id == 21 ) {
$restrict_packages = array( 1, 2, 3, 4, 12 );
}
if ( $package_id == 2 ) {
$restrict_packages = array( 1 );
}
*/
if ( ! empty( $restrict_packages ) ) {
$sql = str_replace( "where status=1 and post_type =", "WHERE status = 1 AND pid NOT IN( '" . implode( "','", $restrict_packages ) . "' ) AND post_type =", $sql );
}
return $sql;
}
add_filter( 'geodir_package_list_query', '_gd_custom_restrict_upgrade_package_query', 10, 2 );
Add above snippet in your child theme functions.php or execute via any PHP snippet plugin.
For example i have used to hide packages 1, 2, 3, 4 from user if current listing being upgrade has package id 12.
Change that lines with your package id.
Thanks,
Kiran