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 / companies-api-curl-example.php
Created August 30, 2023 16:17
Create a company via the api, then create several contacts and link them to the company via the relationships model
<?php
const PUB_KEY = 'abcd';
const TOKEN = '1234';
const URL = 'https://example.com/wp-json/gh/v4';
/**
* Send JSON post
*
* @param $url
@tobeyadr
tobeyadr / new-contact-via-api-wp-remote-post.php
Created August 28, 2023 17:08
Create a contact via the API using wp_remote_post()
<?php
$contact_data = [
// Primary contact data
'data' => [
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john@example.com',
'option_status' => 2, // 1 for unconfirmed, 2 for confirmed,
],
@tobeyadr
tobeyadr / unregister-info-cards.php
Created August 22, 2023 13:00
Unregister info cards that you don't want displayed.
<?php
add_action( 'groundhogg/admin/contacts/register_info_cards', 'remove_unwanted_info_cards', 11 );
/**
* @param $cards \Groundhogg\Admin\Contacts\Info_Cards
*/
function remove_unwanted_info_cards( $cards ){
if ( ! is_super_admin() ){
@tobeyadr
tobeyadr / prevent-company-creation-and-linking.php
Created July 24, 2023 21:09
Prevent companies from being created automatically and from contacts being linked automatically to companies.
<?php
// Auto company creation and linking from forms and the contact record
remove_action( 'groundhogg/after_form_submit', 'GroundhoggCompanies\maybe_create_company_from_contact', 10 );
remove_action( 'groundhogg/companies/save_work_details', 'GroundhoggCompanies\maybe_create_company_from_contact', 10);
// Webhooks
remove_action( 'groundhogg/update_contact_with_map/after', 'GroundhoggCompanies\were_company_changes_made_during_mapping', 10 );
remove_action( 'groundhogg/generate_contact_with_map/after', 'GroundhoggCompanies\were_company_changes_made_during_mapping', 10 );
@tobeyadr
tobeyadr / percentage-of-tags.php
Last active May 10, 2023 20:41
Calculate the percentage of tags a contact has given a list of tag ids
<?php
/**
* Calculates the percentage of tags a contact has from the given tag ids
*
* @param $tag_ids int[]
*
* @return int
*/
function percentage_of_tags( $tag_ids = [] ) {
@tobeyadr
tobeyadr / remove-users-from-owners.php
Created April 20, 2023 15:10
Remove specific users from the owners functionality
<?php
add_filter( 'groundhogg/owners', function ( $users ) {
// Remove users with these IDs
$remove = [ 1234, 4321 ];
$keep = [];
foreach ( $users as $user ){
if ( in_array( $user->ID, $remove ) ){
{
"total_items": 4,
"items": [
{
"ID": 4,
"data": {
"title": "Test Deal",
"deal_value": 300,
"close_probability": 50,
"contact_id": "0",
{
"item": {
"ID": 4,
"data": {
"title": "Test Deal",
"deal_value": 300,
"close_probability": 50,
"contact_id": "0",
"owner_id": 1,
"stage_id": 1,
{
"data" : {
"deal_value": 300,
"priority": 1,
"status": "won"
},
"meta" : {
"product_interest": [
[
"Product Name",
{
"item": {
"ID": 4,
"data": {
"title": "Test Deal",
"deal_value": 300,
"close_probability": 50,
"contact_id": "0",
"owner_id": 1,
"stage_id": 1,