This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check course access | |
function check_ld_access( $can_access, $user_id, $post_id ) { | |
if ( ! function_exists( 'sfwd_lms_has_access' ) ) { | |
return $can_access; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Runs on any post with post type "event" and updates the "Event" custom object with values Title and EventDate | |
function create_update_event_object( $post_id, $post, $update ) { | |
// Don't run if WP Fusion isn't active, otherwise you'll get an error | |
if ( ! function_exists( 'wp_fusion' ) ) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wpf_subscription_products_meta_fields( $fields ) { | |
if ( ! class_exists( 'WC_Subscriptions_Product' ) ) { | |
return; | |
} | |
$args = array( | |
'post_type' => 'product', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wpf_track_login_streak( $meta_id, $user_id, $meta_key, $meta_value ) { | |
if ( 'wpf_last_login' === $meta_key ) { // this runs every time the wpf_last_login field is about to be updated. | |
$prev_value = get_user_meta( $user_id, 'wpf_last_login', true ); // get the previous last login timestamp. | |
$prev_value = floor( absint( $prev_value ) / DAY_IN_SECONDS ); // Convert to days since Jan 1st 1970. |