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 27, 2024 23:52
Redirect request pages if the current user is not vendor or the request author #hivepress #requests
<?php
add_action(
'template_redirect',
function() {
$url = home_url();
$route = hivepress()->router->get_current_route_name();
if ( 'request_view_page' === $route ) {
$post = get_queried_object();
@hivepress
hivepress / functions.php
Created November 24, 2024 20:00
Add region filter to the Listings block settings #hivepress #geolocation
<?php
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
$field_args = [
'label' => 'Region',
'type' => 'select',
'options' => 'terms',
'option_args' => [ 'taxonomy' => 'hp_listing_region' ],
'_order' => 199,
@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( 'messages@example.com', $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
);