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 November 15, 2024 18:14
Send a copy of each new message to a custom email address #hivepress #messages
<?php
add_action(
'hivepress/v1/emails/message_send/send',
function( $email ) {
$tokens = $email->get_tokens();
$subject = 'Message from ' . $tokens['sender']->get_username() . ' to ' . $tokens['recipient']->get_username();
$body = $tokens['message']->get_text();
wp_mail( '[email protected]', $subject, $body );
@hivepress
hivepress / functions.php
Created July 17, 2024 23:59
Allow selecting multiple categories in the back-end listing form #hivepress #listings
<?php
add_filter(
'hivepress/v1/meta_boxes/listing_attributes',
function( $meta_box ) {
if ( isset( $meta_box['fields']['categories'] ) ) {
$meta_box['fields']['categories']['multiple'] = true;
unset( $meta_box['fields']['categories']['attributes']['data-multistep'] );
}
return $meta_box;
@hivepress
hivepress / functions.php
Created February 20, 2023 22:59
Add description to the price extras in the listing form #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['price_extras'] ) ) {
$form['fields']['price_extras']['description'] = 'custom text here';
}
return $form;
},
@hivepress
hivepress / functions.php
Created February 20, 2023 22:58
Add description to the pricing tiers in the listing form #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['price_tiers'] ) ) {
$form['fields']['price_tiers']['description'] = 'custom text here';
}
return $form;
},
@hivepress
hivepress / functions.php
Created February 20, 2023 22:54
Add placeholder text to the listing description field #hivepress #listings
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
$form['fields']['description']['placeholder'] = 'custom text here';
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Created February 20, 2023 22:49
Add description to the Tags field in the listing form #hivepress #tags
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['tags'] ) ) {
$form['fields']['tags']['description'] = 'custom text here';
}
return $form;
},
@hivepress
hivepress / style.css
Created February 20, 2023 22:47
Hide the listing sort drop-down #hivepress #listings
.hp-form--listing-sort {
display: none !important;
}
@hivepress
hivepress / functions.php
Created February 20, 2023 22:36
Change the maximum text length for reviews #hivepress #reviews
<?php
add_filter(
'hivepress/v1/forms/review_submit',
function( $form ) {
$form['fields']['text']['max_length'] = 123;
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Created February 20, 2023 22:34
Require adding at least one price extra to listings #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['price_extras'] ) ) {
$attributes['price_extras']['edit_field']['required'] = true;
}
return $attributes;
},
@hivepress
hivepress / functions.php
Created February 20, 2023 21:17
Make the location field required in the listing search form #hivepress #geolocation
<?php
add_filter(
'hivepress/v1/forms/listing_search',
function( $form ) {
if ( isset( $form['fields']['location'] ) ) {
$form['fields']['location']['required'] = true;
}
return $form;
},