View wpf-ac-resubscribe-to-list.php
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; |
View wpf-learndash-require-enrolled.php
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; | |
} |
View wpf-update-custom-object.php
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; |
View wpf-multisite-meta-keys.php
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. |
View wpf-sync-multiple-subscription-renewal-dates.php
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', |
View wpf-track-login-streak.php
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. |
View wpf-true-auto-login.php
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 | |
// Disbale "Allow URL Login" in WP Fusion's settings for this to work properly. | |
/** | |
* True auto login. Format your URLs like: https://mysite.com/?cid=%CONTACTID%&email=%EMAILADDRESS%&key=%ACCESSKEY% | |
* | |
* Where %CONTACTID% is the ID of the contact | |
* %EMAIL% is the email address of the contact | |
* and %ACCESSKEY% is your access key from the bottom of the WP Fusion General settings tab |
View edd-improved-grandfathered-renewal-discount.php
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 | |
/** | |
* Sets renewal discount to 30% for any customer that purchased before January | |
* 1, 2021. | |
* | |
* @param int $renewal_discount The renewal discount. | |
* @param int $license_id The license ID. | |
* @return int The renewal discount amount. | |
*/ | |
function wpf_edd_grandfather_renewal_discount( $renewal_discount, $license_id ) { |
View wpf-lookup-hubspot-company.php
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 example_hubspot_company_lookup( $user_id ) { | |
$company_id = get_user_meta( $user_id, 'company_id', true ); | |
$request = 'https://api.hubapi.com/crm/v3/objects/companies/' . $company_id; // see https://developers.hubspot.com/docs/api/crm/companies | |
$response = wp_remote_get( $request, wp_fusion()->crm->get_params() ); | |
if ( is_wp_error( $response ) ) { | |
wpf_log( 'error', 0, $response->get_error_message() ); |
View wpf-delete-user-on-tag-update.php
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 | |
// 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' ) ) { |
NewerOlder