This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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. |
This file contains hidden or 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 ) { |
This file contains hidden or 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() ); |
This file contains hidden or 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(), |
This file contains hidden or 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 ) ); |