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-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 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-sync-lifetime-value.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_sync_lifetime_value( $user_meta, $user_id ) { | |
$user_meta['lifetime_value'] = 0; | |
$customer_orders = get_posts( | |
array( | |
'posts_per_page' => -1, | |
'post_type' => 'shop_order', | |
'post_status' => wc_get_is_paid_statuses(), |
View wpf-tag-count.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 | |
// | |
// Tag Count shortcode, use like [wpf_tag_count tag="Tag Name"] | |
// | |
function wpf_tag_count( $atts ) { | |
$tag = wpf_get_tag_id( $atts['tag'] ); | |
$result = get_transient( 'wpf_tag_count_' . sanitize_key( $tag ) ); |
View wpf-restrict-past-content.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 | |
// | |
// Denies access to any content that was published before the user's registration date | |
// | |
function disallow_before_date_published( $can_access, $user_id, $post_id ) { | |
$published = get_the_date( 'U', $post_id ); | |
$userdata = get_userdata( $user_id ); |
View wpf-daily-import.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 every day and imports any new users from the connected CRM who have the specified tag ID ("123" in this example) | |
// If contacts with that tag already have user accounts on the site they will be skipped and no data will be loaded | |
// i.e. this just imports *new* users | |
if ( ! wp_next_scheduled( 'wpf_daily_import' ) ) { | |
wp_schedule_event( time(), 'daily', 'wpf_daily_import' ); | |
} |
View wpf-fooevents-multiple-bookings.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_bookable_products_meta_fields( $fields ) { | |
$args = array( | |
'post_type' => 'product', | |
'nopaging' => true, | |
'meta_key' => 'WooCommerceEventsType', | |
'meta_value' => 'bookings', | |
); |
NewerOlder