Skip to content

Instantly share code, notes, and snippets.

View jack-arturo's full-sized avatar

Jack Arturo jack-arturo

View GitHub Profile
@jack-arturo
jack-arturo / wpf-limit-tags.php
Created March 11, 2021 11:06
Limit the number of tags loaded from the CRM to 1000
<?php
// Limit number of tags loaded. More than 1000 tags can cause slowness in the interfaces
add_filter( 'wpf_set_setting_available_tags', function( $tags ) {
return array_slice( $tags, 0, 1000 );
} );
@jack-arturo
jack-arturo / wpf-restrict-past-content.php
Last active January 4, 2021 11:49
Denies access to any content that was published before the user's registration date
<?php
//
// Denies access to any content that was published before the user's registration date
//
function disallow_before_date_published( $can_access, $user_id, $post_id ) {
$published = get_the_date( 'U', $post_id );
$userdata = get_userdata( $user_id );
@jack-arturo
jack-arturo / wpf-daily-import.php
Created December 11, 2020 14:02
Creates a daily cron to run an Import Users operation via WP Fusion
<?php
// This runs every day and imports any new users from the connected CRM who have the specified tag ID ("123" in this example)
// If contacts with that tag already have user accounts on the site they will be skipped and no data will be loaded
// i.e. this just imports *new* users
if ( ! wp_next_scheduled( 'wpf_daily_import' ) ) {
wp_schedule_event( time(), 'daily', 'wpf_daily_import' );
}
@jack-arturo
jack-arturo / wpf-fooevents-multiple-bookings.php
Created November 19, 2020 11:13
Allows syncing the booking date from multiple FooEvents Bookings products to multiple fields in your CRM
<?php
function wpf_bookable_products_meta_fields( $fields ) {
$args = array(
'post_type' => 'product',
'nopaging' => true,
'meta_key' => 'WooCommerceEventsType',
'meta_value' => 'bookings',
);
@jack-arturo
jack-arturo / edd-calculate-lifetime-upgrade.php
Created November 3, 2020 10:01
Calculate the upgrade cost of an EDD license from annual to lifetime
<?php
// 3 is the upgrade ID of a 1 site lifetime license
// 4 is the upgrade ID of a 3 sites lifetime license
// 1 to 4 are the price IDs of annual licenses
// 5 is the price ID of a 1 site lifetime license
// 6 is the price ID of a 3 site lifetime license
function wpf_edd_sl_upgrade_cost( $cost, $license_id, $upgrade_id ) {
@jack-arturo
jack-arturo / wpf-woocommerce-sync-processing-orders.php
Created October 2, 2020 10:04
Makes WP Fusion send Enhanced Ecommerce data when a WooCommerce order is created in Pending status, instead of waiting for Processing
<?php
//
// Makes WP Fusion send Enhanced Ecommerce data when a WooCommerce order is created in Pending status, instead of waiting for Processing
//
function wpf_woocommerce_run_on_pending( $order_id ) {
if ( ! function_exists( 'wp_fusion' ) ) {
return;
@jack-arturo
jack-arturo / wpf-extend-http-timeout.php
Created July 19, 2020 08:02
Extends the HTTP timeout to 60 seconds
<?php
function wpf_extend_timeout( $args, $url ) {
$args['timeout'] = 60;
return $args;
}
@jack-arturo
jack-arturo / wpf-gravity-forms-salesforce-custom-object.php
Created July 7, 2020 05:35
Create a custom object in Salesforce after a Gravity Forms submission
<?php
/***********************************************************************
* Salesforce Create Inquiry
***********************************************************************/
function red_new_business_inquiry_submission( $entry, $form ) {
// Switch Salesforce integration to the Inquiry_Form__c object type
@jack-arturo
jack-arturo / hide-widget-from-logged-in-users.php
Last active May 29, 2020 13:48
Simple snippet for adding a checkbox to hide widgets from logged in users
<?php
// Widget form
function cust_widget_form( $widget, $return, $instance ) {
if( ! isset( $instance['logged_out_only'] ) ) {
$instance['logged_out_only'] = false;
} ?>
@jack-arturo
jack-arturo / wpf-skip-contact-creation-on-field.php
Created April 29, 2020 09:20
Conditionally disable WP Fusion from syncing new contacts to your CRM based on a user_meta field value
<?php
function skip_contact_creation( $user_meta, $user_id ) {
if ( isset( $user_meta['receive_press_releases'] ) && true != $user_meta['receive_press_releases'] ) {
$user_meta = null;
}
return $user_meta;