4Bids developer reference
Overview
4Bids is an online bidding/offers module for properties. Users register, get approved per property, then can place offers (Private Treaty) or bid in timed auctions. Offers are stored as a custom post type offer; notifications (outbid, watchers, agent) and optional Acquaint CRM sync are supported.
Load order
- wp-property-drive.php loads
modules/4bids/autoload.php(unconditionally). - autoload.php requires:
cpt-bids.php→4bids-functions.php→4bids.php→user-fields.php→offer-fields.php→build-bids-page.php→api-offers.php, then hooksafter_slider→wppd_4bids_bidding_container.
Entry points
- Single property page:
templates/single-property.phprunsdo_action( 'after_slider', $property_id ). That fireswppd_4bids_bidding_container( $property_id ), which echoesget_bidding_container( $property_id )from 4bids.php. - Admin: 4Bids Settings submenu
pd_bids(PRO only) →jtg_build_bids_page()in build-bids-page.php (Dashboard, Settings, Pending, Invoices, Email, Bids tabs). - CPT:
offerpost type registered in cpt-bids.php (show_in_menu = property_drive when PRO). Bulk/row delete disabled for offers.
Key data
- Property meta:
_bidding_enabled,_bidding_method(1 = Private Treaty, else auction),_bidding_start_datetime,_bidding_end_datetime,_bid_increment_override,wppd_price_minimum(bid floor starting price),wppd_price_reserve(reserve price, also used as bid floor fallback),wppd_4bids_*(custom status, HTML, legal packs, agent email, etc.). - Offer CPT:
bid_value,bid_property_id,bid_is_cancelled,bid_cancelled_reason. - User meta:
user_pending_properties,user_approved_properties,wppd_user_role(e.g. watcher),bid_notify(per-property array[ property_id => 1|0 ]; legacy: scalar 1/0),ext_phone, etc.
Flow: placing an offer
- Front-end: User (verified for that property) sees bidding UI from
get_bidding_container(): latest bid, stepper, history, settings (notify toggle). Script init.js posts towppd_store_offer(orwppd_store_offer_acquaint_apiwhen Acquaint used). - api-offers.php
wppd_store_offer(): Reads JSON (pid, author, amount). Server-side bid floor check: rejects ifamountis belowmax(wppd_price_minimum → wppd_price_reserve → price, highest_bid). Checks no existing non-cancelled offer with same amount for same property. Createsofferpost, sets meta. Then: callswppd_4bids_notify_on_new_offer()(outbid, watchers, agent) and sends abid-confirmationemail to the bidder; applies rollover (extends end time if within interval); returnswp_send_json_success( { message, data: offer_id } ). - wppd_notify_bidders (4bids.php): Separate AJAX action (nonce-protected via
check_ajax_referer; also registered fornopriv). Delegates towppd_4bids_notify_on_new_offer(). Can be called from JS independently (e.g. if the Acquaint path is used and local notifications need to fire separately).
Flow: Acquaint
- If Acquaint API key/id set, JS may call
wppd_store_offer_acquaint_apiwith user details + list_reference + amount. Server sends offer to Acquaint API; response echoed as JSON. List reference is stripped ofwppd_acquaint_idprefix before use.
Core helpers (4bids-functions.php)
- wppd_user_has_bid_notify( $user_id, $property_id ): Checks per-property (or global legacy) notification preference. Pass
$property_id = 0for any-property check. Handles both array meta and legacy scalarbid_notify. - wppd_4bids_get_latest_bids( $pid, $author, $limit, $skip_withdrawn = 1 ): Returns
[ 'bids' => [ ['bid','author','value','date','pid','is_cancelled'], ... ] ]. Used for history, latest bid value, “your bid”, agent email table. Return type is always array with ‘bids’ key. - wppd_4bids_get_bid_count( $pid ): Count of non-cancelled offers for property.
- wppd_4bids_get_bidders( $pid ): Returns list of bidders (authors) for notifications.
- wppd_4bids_notify_on_new_offer( $property_id, $author_id ): Central dispatcher called after a new offer is stored; sends outbid, watcher, and agent notification emails.
- wppd_4bids_get_user_approval( $user_id, $property_id ): Whether user is approved to bid on that property.
- supernova_trigger_email( $type, … ): Dispatches 4Bids emails (bid-confirmation, outbid, watch, agent-notification, offer-cancel, offer-withdrawn, user-title-change, 4bids-application).
AJAX (summary)
- wppd_store_offer (api-offers): Store offer with server-side bid floor check, notify, rollover,
wp_send_json_success/error. - wppd_store_offer_acquaint_api (api-offers): Send offer to Acquaint API,
wp_send_json. - wppd_withdraw_offer_acquaint_api (api-offers): Withdraw offer in Acquaint (sets statusId to 3). Noop if no Acquaint credentials.
- wppd_get_offers (api-offers): Returns JSON
{ bids }ordered by date DESC (vs.wppd_4bids_get_latest_bidswhich orders by bid_value DESC). - wppd_get_offer_details (api-offers): Returns details for a single offer post.
- wppd_extend_bid, wppd_store_download, wppd_notify_bidders (nonce-protected, also nopriv), wppd_cancel_bid, wppd_update_auction_details, update_bidder_notification, wppd_4bids_delete_bid (4bids.php): Various; most respond with
wp_die()only;wppd_update_auction_detailsechoes HTML;wppd_4bids_delete_biduseswp_send_json.
Scripts / assets
- 4bids.php: Enqueues
4bids-core(init.js) and 4bids.css on front; enqueues4bids-admin(admin.js) in admin. Inline vars: ajaxurl, apiurl, bid_interval, bid_increment, self_id, property_id, notify_bidders_nonce (front only). - init.js: Fetches for store_offer, store_offer_acquaint_api, get_offers, extend_bid, store_download, etc.
Integration with rest of plugin
- property-grid-functions.php: Can filter by grid_type 4bids-private-treaty / 4bids-auction (meta _bidding_enabled, _bidding_method).
- build-admin-page.php: Importer/4Bids settings, Labs, CRON, etc.
- user-account.php / user-registration.php: User fields and approval for 4Bids.
- cpt-bids.php: Also adds property row actions (Set to Draft, Lock Property) and removes Quick Edit for property; handles set_to_draft and lock_property.