Skip to content

Instantly share code, notes, and snippets.

View verygoodplugins's full-sized avatar

Very Good Plugins verygoodplugins

View GitHub Profile
@verygoodplugins
verygoodplugins / my-plugin.php
Created December 8, 2022 11:38
WordPress plugin created by ChatGPT (https://i.wpfusion.com/8p22pV)
<?php
// Define a class for our plugin
class MyPlugin {
// Define a static property to hold the single instance of the class
private static $instance;
// Define a private constructor to prevent the class from being instantiated directly
private function __construct() {
// Add the admin settings page to the WordPress admin menu
@verygoodplugins
verygoodplugins / wpf-lock-user-for-webhooks.php
Last active March 8, 2023 11:45
Blocks incoming webhooks for a user for one minute after tags were applied to them (to prevent loopbacks)
<?php
/**
* Sets a transient to lock a user from receiving webhooks from the CRM for one minute
* after tags have been applied by WP Fusion.
*
* @param int $user_id The user ID.
*/
function wpf_lock_user( $user_id ) {
@verygoodplugins
verygoodplugins / copy-memberium-auto-enroll-tags.php
Last active December 6, 2022 10:55
Copies Memberium's LearnDash auto-enroll tags over to WP Fusion's Link With Tag setting
<?php
function maybe_migrate_auto_enroll_tags() {
// visit /wp-admin/index.php?migrate=true to start.
if ( isset( $_GET['migrate'] ) ) {
$linked_courses = get_posts(
array(
@verygoodplugins
verygoodplugins / inherit-memberium-access-rules.php
Last active December 7, 2022 10:48
Makes WP Fusion inherit post access rules and redirects that were created in Memberium
<?php
function inherit_memberium_access_rules( $settings, $post_id ) {
if ( is_object( $post_id ) ) {
$post_id = $post_id->ID; // wpf_settings_for_meta_box passes a WP_Post.
}
if ( empty( $settings['allow_tags'] ) ) {
@verygoodplugins
verygoodplugins / edd-custom-cancel.php
Created November 1, 2022 09:59
Modifies the Easy Digital Downloads cancellation link to point to a custom "Confirm cancellation" page
<?php
/**
* Modify the EDD cancel URL to point custom cancellation page.
*
* @param string $url The cancel URL.
* @param EDD_Subscription $subscription The subscription.
*/
function wpf_edd_subscription_cancel_url( $url, $subscription ) {
@verygoodplugins
verygoodplugins / set-infusionsoft-tracking-cookie.php
Created September 9, 2022 09:43
Sets the Infusionsoft referral partner tracking cookie based on a URL parameter, so it can be passed to a subdomain.
@verygoodplugins
verygoodplugins / wpf-sync-pending-yith-quotes.php
Created September 6, 2022 12:31
Sync YITH Request A Quote pending orders to ActiveCampaign Deep Data as if they'd already been paid for
<?php
// Sync YITH Request A Quote pending orders to AC as if they'd been paid.
function add_custom_paid_status( $statuses ) {
$statuses[] = 'ywraq-new';
$statuses[] = 'ywraq-pending';
return $statuses;
@verygoodplugins
verygoodplugins / tag-based-on-username.php
Created July 22, 2022 08:33
When a user registers in WordPress, applies a tag in the CRM with their username
<?php
function tag_based_on_username( $user_id ) {
$user = get_user_by( 'id', $user_id );
wp_fusion()->user->apply_tags( array( $user->user_login ), $user_id );
}
@verygoodplugins
verygoodplugins / wpf-ac-resubscribe-to-list.php
Created June 2, 2022 13:20
Re-susbscribes an unsubscribed contact to the selected list when their profile is updated
<?php
// This runs whenever WP Fusion updates an existing contact record. It re-subscribes them to the list ID specified.
function re_subscribe_to_list( $args ) {
$list_id = 1; // Update this with your list ID.
$args[1][ 'p[' . $list_id . ']' ] = $list_id;
$args[1][ 'status[' . $list_id . ']' ] = 1;
@verygoodplugins
verygoodplugins / wpf-multisite-meta-keys.php
Last active November 15, 2021 15:11
Prefix the WPF contact ID and tags meta keys with the current blog prefix
<?php
/**
* When the user's contact ID or tags are saved, prefix the usermeta key with
* the blog prefix of the current blog.
*
* @param bool $check Whether or not to bypass the original database
* check.
* @param int $user_id The user ID.
* @param string $meta_key The meta key.