Skip to content

Instantly share code, notes, and snippets.

View hivepress's full-sized avatar

HivePress hivepress

View GitHub Profile
@hivepress
hivepress / functions.php
Created February 20, 2023 20:28
Restrict making offers to vendors with at least 1 listing #hivepress #requests
<?php
add_filter(
'hivepress/v1/forms/offer_make/errors',
function( $errors ) {
$listing_id = \HivePress\Models\Listing::query()->filter(
[
'status' => 'publish',
'user' => get_current_user_id(),
]
)->get_first_id();
@hivepress
hivepress / functions.php
Created February 20, 2023 20:18
Remove options for sorting listings by rating #hivepress #reviews
<?php
add_filter(
'hivepress/v1/forms/listing_sort',
function( $form ) {
unset( $form['fields']['_sort']['options']['rating__asc'], $form['fields']['_sort']['options']['rating__desc'] );
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Last active February 20, 2023 20:13
Remove the text field from reviews #hivepress #reviews
<?php
add_filter(
'hivepress/v1/forms/review_submit',
function( $form ) {
unset( $form['fields']['text'] );
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Created February 20, 2023 20:08
Remove the price range search filter for listings #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/forms/listing_filter',
function( $form ) {
unset($form['fields']['price']);
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Created December 7, 2022 15:55
Change the Add Details page title for listings #hivepress #listings
<?php
add_filter(
'hivepress/v1/routes',
function( $routes ) {
$routes['listing_submit_details_page']['title'] = 'Custom title here';
return $routes;
},
1000
);
@hivepress
hivepress / functions.php
Last active June 8, 2023 00:43
Add vendor profile link to the user account menu #hivepress #vendors
<?php
add_filter(
'hivepress/v1/menus/user_account',
function ( $menu ) {
if ( is_user_logged_in() ) {
$vendor_id = HivePress\Models\Vendor::query()->filter(
[
'user' => get_current_user_id(),
]
)->get_first_id();
@hivepress
hivepress / functions.php
Created July 23, 2022 23:36
Add vendor email link to the listing page #hivepress #listings
<?php
add_filter(
'hivepress/v1/templates/listing_view_page/blocks',
function( $blocks, $template ) {
$listing = $template->get_context( 'listing' );
if ( $listing ) {
$blocks = hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
@hivepress
hivepress / functions.php
Created July 23, 2022 23:29
Make the profile description field required #hivepress #users
<?php
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
$form['fields']['description']['required'] = true;
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Last active July 26, 2023 17:21
Change the price display format for bookable listings #hivepress #listings #bookings
<?php
add_filter(
'hivepress/v1/models/listing/fields',
function( $fields, $model ) {
if ( isset( $fields['price'] ) ) {
$fields['price']['display_template'] = '%value% / day';
}
return $fields;
},
@hivepress
hivepress / functions.php
Created July 23, 2022 23:24
Restrict email domains for newly registered users #hivepress #users
<?php
add_filter(
'hivepress/v1/forms/user_register/errors',
function( $errors, $form ) {
if ( ! $errors ) {
$domain = hivepress()->helper->get_last_array_value( explode( '@', $form->get_value( 'email' ) ) );
if ( ! in_array(
$domain,
[