Skip to content

Instantly share code, notes, and snippets.

View verygoodplugins's full-sized avatar

Very Good Plugins verygoodplugins

View GitHub Profile
<?php
// Deletes WordPress user when the tag "REMOVE USER" is applied.
// Works when a webhook is received or during a batch Resync Tags operation is run.
// USE WITH CAUTION.
function my_wpf_delete_user( $user_id, $user_tags ) {
if ( wp_fusion()->user->has_tag( 'REMOVE USER', $user_id ) && ! user_can( $user_id, 'manage_options' ) ) {
@verygoodplugins
verygoodplugins / wpf-apply-tags-order-hold.php
Last active April 7, 2017 14:27
Applies tags to users when order is placed On Hold (cheque payments)
<?php
// Applies tags to users when order is placed On Hold (cheque payments)
add_action( 'woocommerce_order_status_on-hold', 'custom_wpf_woo_on_hold' );
function custom_wpf_woo_on_hold( $order_id ) {
$order = new WC_Order( $order_id );
$user = get_user_by( 'email', $order->billing_email );
@verygoodplugins
verygoodplugins / wpf-awp-change-urls.php
Created June 8, 2017 08:11
Change Affiliate WP URLs to include affiliate email/ID in URL
<?php
function custom_awp_url($url) {
$user_meta = wp_get_current_user();
$user_email = $user_meta->user_email;
$url = $url . '?leadsource=' . urlencode($user_email);
@verygoodplugins
verygoodplugins / wpf-flip-access-rules.php
Last active December 13, 2018 17:20
Flips the access rules for a post or posts so that users *without* any of the specified tags are granted access
<?php
add_filter('wpf_user_can_access', 'my_wpf_flip_access_rules', 10, 3);
function my_wpf_flip_access_rules( $can_access, $user_id, $post_id ) {
// Optional: limit the rule flipping just to certain post IDs (1234 and 4567)
if( $post_id != 1234 ) {
return $can_access;
}
@verygoodplugins
verygoodplugins / alt-shortcodes.php
Last active February 15, 2021 23:21
Allow [wpf] shortcodes inside of eachother
<?php
function wpf_alt_shortcode() {
if( ! is_admin() ) {
$wpf_shortcodes = new WPF_Shortcodes;
add_shortcode( 'wpf2', array( $wpf_shortcodes, 'shortcodes' ) );
}
}
@verygoodplugins
verygoodplugins / wpf-hot-swap-ac-by-role.php
Last active June 5, 2020 16:54
Connect WP Fusion to two ActiveCampaign accounts and sync users depending on their role
<?php
/*
Plugin Name: AC Account Switch
Description: Switches AC API credentials for WP Fusion depending on user role
Plugin URI: https://verygoodplugins.com/
Version: 1.0
Author: Very Good Plugins
Author URI: https://verygoodplugins.com/
*/
@verygoodplugins
verygoodplugins / wpf-intercom-connect.php
Last active March 13, 2024 22:47
Add new contacts to an alternate CRM (Intercom) when a user registers, and apply tags in Intercom when tags are applied in the primary CRM
<?php
// Put your intercom access token here
define( 'INTERCOM_ACCESS_TOKEN', 'aG9tOjyIyZmMxZDc2X2YxMzBfNDBhZV9hOTVjXzRhZDRlNzBiZWMyMzoxOjA=' );
// We'll save the alternate CRM in a global so it can be re-used if multiple API calls need to be made in the same request
global $intercom;
@verygoodplugins
verygoodplugins / wpf-tags-as-body-classes.php
Last active December 14, 2023 13:22
Add tags as classes to the body
<?php
// Adds a current logged in users tags to the <body> element's classes.
function wpf_tags_body_class( $classes ) {
if ( ! function_exists( 'wp_fusion' ) ) {
return $classes;
}
@verygoodplugins
verygoodplugins / wpf-remove-empty-meta.fields.php
Created May 15, 2018 12:26
Deletes user meta fields if the data loaded from the CRM is missing or empty
<?php
// Deletes user meta fields if the data loaded from the CRM is missing or empty
function wpf_remove_empty_meta_fields( $user_id, $user_meta ) {
$contact_fields = wp_fusion()->settings->get( 'contact_fields' );
foreach ( $contact_fields as $field_id => $field_data ) {
@verygoodplugins
verygoodplugins / wpf-gravity-forms-multiple-contacts.php
Created June 6, 2018 16:39
Adds additional contacts to Infusionsoft when a Gravity Form is submitted
<?php
function my_gform_after_submission( $entry, $form ) {
// Gets the first name and last name from field ID 3, and email from field ID 4
$contact_data = array(
'FirstName' => rgar( $entry, '3.3' ),
'LastName' => rgar( $entry, '3.6' ),
'Email' => rgar( $entry, '4' )
);