Skip to content

Instantly share code, notes, and snippets.

View tobeyadr's full-sized avatar
🎯
Focusing

Adrian Tobey tobeyadr

🎯
Focusing
View GitHub Profile
@tobeyadr
tobeyadr / appointment-conversion-wrapper.php
Last active March 8, 2024 22:15
JS to listen for when the details form is submitted in the calendar.
<?php
add_action( 'enqueue_groundhogg_calendar_scripts', function (){
// language=javascript
$script = 'document.addEventListener("submit", function(event) {
// Check if the submitted element is a form with the specific class name
if (event.target.matches("form.details-form")) {
// Do GA stuff
}
});';
@tobeyadr
tobeyadr / extend-auth-cookie-expiration.php
Created March 5, 2024 14:44
Extend the authorization of the cookie expiration.
@tobeyadr
tobeyadr / track-live-activity-example.php
Created December 22, 2023 18:12
An example of use the track_live_activity() function
<?php
add_action( 'favorites_post', 'track_activity_when_post_is_favorited' );
/**
* Tracks activity in Groundhogg when a user marks their post as favorite
*
* @param $post WP_Post
*
* @return void
@tobeyadr
tobeyadr / memberpress-set-optin-status-and-consent.php
Created December 21, 2023 18:22
When a member becomes active in MemberPress change their opt-in status to confirmed and set their consents
@tobeyadr
tobeyadr / prevent-sales-reps-from-importing-owner.php
Last active December 20, 2023 17:34
Prevent sales reps from importing the owner
<?php
add_action( 'groundhogg/generate_contact_with_map/before', 'prevent_sales_reps_from_importing_owner', 10, 2 );
/**
* Removes the field mapping for the contact owner if the current user does not have edit_others_contacts permissions
*
* @param $fields array
* @param $map array
@tobeyadr
tobeyadr / renew-expired-licenses-with-deafult-price-id.php
Created December 20, 2023 16:28
Set price_id to download default if license is expired for over 3 months
<?php
add_filter( 'edd_add_to_cart_item', 'update_price_id_during_renewal_if_license_expired_past_3_months', 10, 1 );
/**
* Update the price_id to the download's default if the license is expired by 3 months
*
* @param $item
*
* @return array the item
@tobeyadr
tobeyadr / set-custom-field-from-cookie-after-form-submit.php
Last active October 31, 2023 13:37
Update the value of contact's custom field after a form is submitted. Works for all form integrations, standard forms, legacy forms, and payment forms.
@tobeyadr
tobeyadr / register-custom-replacement-codes.php
Last active October 17, 2023 23:17
Register a custom replacement code and group
<?php
add_action( 'groundhogg/replacements/init', 'register_my_custom_replacement_codes' );
/**
* Register any custom replacement codes
*
* @param $replacements \Groundhogg\Replacements
*/
function register_my_custom_replacement_codes( $replacements ) {
@tobeyadr
tobeyadr / filter-zb-status.php
Created September 28, 2023 18:59
Filter the ZeroBounce status before an API call is made to add your own validation logic.
<?php
add_filter( 'groundhogg/zerobounce/zb_status', 'filter_zb_status', 10, 2 );
/**
* Filter the status
*
* @param string|false $status
* @param \Groundhogg\Contact $contact
*
@tobeyadr
tobeyadr / review-next-affiliate.php
Last active September 20, 2023 13:15
After an affiliate is reviewed, this script will take you to the review page of the next pending affiliate, rather than back to the main list.
<?php
/**
* After an affiliate is accepted/rejected from the review page, review the next affiliate automatically
*
* @param $url
* @param $type
* @param $query_args
*
* @return mixed|string