PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0.7
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0.7
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / compat / charitable-ultimate-member-compat-functions.php

charitable-ultimate-member-compat-functions.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.7.0.7, at includes/compat/charitable-ultimate-member-compat-functions.php

72 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions to improve compatibility with Ultimate Member.
4 *
5 * @package Charitable/Functions/Compatibility
6 * @author David Bisset
7 * @copyright Copyright (c) 2022, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.6.25
10 * @version 1.6.25
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * When a user verifies their email through Ultimate Member's flow,
20 * mark them as verified in Charitable too.
21 *
22 * @since 1.6.25
23 *
24 * @param int $user_id The user ID.
25 * @return void
26 */
27 function charitable_um_after_user_verified_email( $user_id ) {
28 if ( ! array_key_exists( 'act', $_REQUEST ) || ! array_key_exists( 'hash', $_REQUEST ) ) {
29 return;
30 }
31
32 if ( 'activate_via_email' != $_REQUEST['act'] || ! is_string( $_REQUEST['hash'] ) ) {
33 return;
34 }
35
36 $user = charitable_get_user( $user_id );
37 $user->mark_as_verified( true );
38 }
39
40 add_action( 'um_after_user_is_approved', 'charitable_um_after_user_verified_email' );
41
42
43 /**
44 * If the Profile page setting in Charitable is set to the same page
45 * as the User page in Ultimate Member, it messes up with our endpoints.
46 *
47 * Therefore, to correctly catch which endpoint is being shown, we need
48 * to check for the um_user query var and see if it's set to a value indicating
49 * it's one of our endpoints.
50 *
51 * @global WP_Query $wp_query;
52 * @param boolean $is_page Whether this is the particular endpoint page.
53 * @return boolean
54 */
55 function charitable_um_is_page_charitable_endpoint( $is_page ) {
56 if ( UM()->options()->get( 'core_user' ) != charitable_get_option( 'profile_page' ) ) {
57 return $is_page;
58 }
59
60 global $wp_query;
61
62 switch ( current_filter() ) {
63 case 'charitable_is_page_email_verification_page':
64 return $wp_query->is_main_query()
65 && array_key_exists( 'um_user', $wp_query->query_vars ) && 'email-verification' == $wp_query->query_vars['um_user'];
66 }
67
68 return $is_page;
69 }
70
71 add_filter( 'charitable_is_page_email_verification_page', 'charitable_um_is_page_charitable_endpoint' );
72