Skip to content

Instantly share code, notes, and snippets.

Avatar

Very Good Plugins verygoodplugins

View GitHub Profile
@verygoodplugins
verygoodplugins / wpf-extend-http-timeout.php
Created Jul 19, 2020
Extends the HTTP timeout to 60 seconds
View wpf-extend-http-timeout.php
<?php
function wpf_extend_timeout( $args, $url ) {
$args['timeout'] = 60;
return $args;
}
@verygoodplugins
verygoodplugins / wpf-gravity-forms-salesforce-custom-object.php
Created Jul 7, 2020
Create a custom object in Salesforce after a Gravity Forms submission
View wpf-gravity-forms-salesforce-custom-object.php
<?php
/***********************************************************************
* Salesforce Create Inquiry
***********************************************************************/
function red_new_business_inquiry_submission( $entry, $form ) {
// Switch Salesforce integration to the Inquiry_Form__c object type
@verygoodplugins
verygoodplugins / hide-widget-from-logged-in-users.php
Last active May 29, 2020
Simple snippet for adding a checkbox to hide widgets from logged in users
View hide-widget-from-logged-in-users.php
<?php
// Widget form
function cust_widget_form( $widget, $return, $instance ) {
if( ! isset( $instance['logged_out_only'] ) ) {
$instance['logged_out_only'] = false;
} ?>
@verygoodplugins
verygoodplugins / wpf-skip-contact-creation-on-field.php
Created Apr 29, 2020
Conditionally disable WP Fusion from syncing new contacts to your CRM based on a user_meta field value
View wpf-skip-contact-creation-on-field.php
<?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;
@verygoodplugins
verygoodplugins / wpf-delete-user-on-field-change.php
Created Apr 22, 2020
Deletes WordPress user when the "role" field is loaded from the CRM with a value of "deleted"
View wpf-delete-user-on-field-change.php
<?php
// Deletes WordPress user when the "role" field is loaded from the CRM with a value of "deleted"
// Works when a webhook is received or a batch Pull User Meta operation is run.
function my_wpf_delete_user_by_field( $user_id, $user_meta ) {
if ( isset( $user_meta['role'] ) && $user_meta['role'] == 'deleted' && ! user_can( $user_id, 'manage_options' ) ) {
wp_delete_user( $user_id );
@verygoodplugins
verygoodplugins / wpf-learndash-require-enrolled.php
Created Apr 21, 2020
Modifies WP Fusion's course access permissions for LearnDash so users must be enrolled in the course to see the course page
View wpf-learndash-require-enrolled.php
<?php
// Check course access
function check_ld_access( $can_access, $user_id, $post_id ) {
if ( ! function_exists( 'sfwd_lms_has_access' ) ) {
return $can_access;
}
@verygoodplugins
verygoodplugins / wpf-sync-learndash-quiz-progress.php
Last active Apr 13, 2020
Sync LearnDash quiz results to custom fields in the CRM
View wpf-sync-learndash-quiz-progress.php
<?php
// Register the quiz fields in the WPF settings
function wpf_add_learndash_quiz_fields( $meta_fields ) {
$args = array(
'post_type' => 'sfwd-quiz',
'nopaging' => true,
);
@verygoodplugins
verygoodplugins / wpf-allow-rss.php
Last active Mar 24, 2020
Bypass WP Fusion's content restriction on RSS feed content
View wpf-allow-rss.php
<?php
function wpf_allow_rss( $can_access, $user_id, $post_id ) {
if ( is_feed() ) {
$can_access = true;
}
return $can_access;
@verygoodplugins
verygoodplugins / wpf-sync-multiple-subscription-renewal-dates.php
Created Feb 7, 2020
Allows syncing the renewal dates from multiple WooCommerce subscriptions into multiple custom fields
View wpf-sync-multiple-subscription-renewal-dates.php
<?php
// Add the subscription renewal date fields to the Contact Fields list in the WP Fusion settings
function wpf_subscription_products_meta_fields( $fields ) {
if ( ! class_exists( 'WC_Subscriptions_Product' ) ) {
return;
}
@verygoodplugins
verygoodplugins / wpf-load-empty-values.php
Created Jan 21, 2020
By default WP Fusion will not erase data in WordPress if a field is blank in the CRM. This function tells WP Fusion to erase WordPress data if a CRM field is blank. Use with caution.
View wpf-load-empty-values.php
<?php
// By default WP Fusion will not erase data in WordPress if a field is blank in the CRM.
// This function tells WP Fusion to erase WordPress data if a CRM field is blank.
// Use with caution.
function set_values_to_null( $user_meta, $user_id ) {
foreach ( $user_meta as $key => $value ) {
You can’t perform that action at this time.