| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable User Management Hooks |
| 4 |
* |
| 5 |
* @package Charitable/User Management/User Management |
| 6 |
* @author Rafe Colton |
| 7 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.4.0 |
| 10 |
* @version 1.4.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Fire off the password reset request. |
| 20 |
* |
| 21 |
* @see Charitable_Forgot_Password_Form::retrieve_password() |
| 22 |
*/ |
| 23 |
add_action( 'charitable_retrieve_password', array( 'Charitable_Forgot_Password_Form', 'retrieve_password' ) ); |
| 24 |
|
| 25 |
/** |
| 26 |
* Reset a user's password. |
| 27 |
* |
| 28 |
* @see Charitable_Reset_Password_Form::reset_password() |
| 29 |
*/ |
| 30 |
add_action( 'charitable_reset_password', array( 'Charitable_Reset_Password_Form', 'reset_password' ) ); |
| 31 |
|
| 32 |
/** |
| 33 |
* Save a profile. |
| 34 |
* |
| 35 |
* @see Charitable_Profile_Form::update_profile() |
| 36 |
*/ |
| 37 |
add_action( 'charitable_update_profile', array( 'Charitable_Profile_Form', 'update_profile' ) ); |
| 38 |
|
| 39 |
/** |
| 40 |
* Save a user after registration. |
| 41 |
* |
| 42 |
* @see Charitable_Registration_Form::save_registration() |
| 43 |
*/ |
| 44 |
add_action( 'charitable_save_registration', array( 'Charitable_Registration_Form', 'save_registration' ) ); |
| 45 |
|
| 46 |
/** |
| 47 |
* Display any notices before the login, profile and donation history pages. |
| 48 |
* |
| 49 |
* @see charitable_template_notices |
| 50 |
*/ |
| 51 |
add_action( 'charitable_login_form_before', 'charitable_template_notices', 10, 0 ); |
| 52 |
add_action( 'charitable_my_donations_before', 'charitable_template_notices', 10, 0 ); |
| 53 |
|
| 54 |
/** |
| 55 |
* Add support for deprecated `charitable_user_profile_after_fields` hook. |
| 56 |
* |
| 57 |
* @see Charitable_Profile_Form::add_deprecated_charitable_user_profile_after_fields_hook() |
| 58 |
*/ |
| 59 |
add_action( 'charitable_form_after_fields', array( 'Charitable_Profile_Form', 'add_deprecated_charitable_user_profile_after_fields_hook' ) ); |
| 60 |
|
| 61 |
/** |
| 62 |
* Redirect the user to the password reset page with the query string removed. |
| 63 |
* |
| 64 |
* @see Charitable_User_Management::maybe_redirect_to_password_reset() |
| 65 |
*/ |
| 66 |
add_action( 'template_redirect', array( Charitable_User_Management::get_instance(), 'maybe_redirect_to_password_reset' ) ); |
| 67 |
|
| 68 |
/** |
| 69 |
* Hides the WP Admin bar if the current user is not allowed to view it. |
| 70 |
* |
| 71 |
* @see Charitable_User_Management::remove_admin_bar() |
| 72 |
*/ |
| 73 |
add_action( 'after_setup_theme', array( Charitable_User_Management::get_instance(), 'maybe_remove_admin_bar' ) ); |
| 74 |
|
| 75 |
/** |
| 76 |
* Redirects the user away from /wp-admin if they are not authorized to access it. |
| 77 |
* |
| 78 |
* @see Charitable_User_Management::maybe_redirect_away_from_admin() |
| 79 |
*/ |
| 80 |
add_action( 'admin_init', array( Charitable_User_Management::get_instance(), 'maybe_redirect_away_from_admin' ) ); |
| 81 |
|
| 82 |
/** |
| 83 |
* If desired, all access to wp-login.php can be redirected to the Charitable login page. |
| 84 |
* |
| 85 |
* This is switched off by default. To enable this option, you need to set a Charitable |
| 86 |
* login page and also return true for the filter: |
| 87 |
* |
| 88 |
* add_filter( 'charitable_disable_wp_login', '__return_true' ); |
| 89 |
* |
| 90 |
* @see Charitable_User_Management::redirect_to_charitable_login() |
| 91 |
*/ |
| 92 |
add_action( 'login_form_login', array( Charitable_User_Management::get_instance(), 'maybe_redirect_to_charitable_login' ) ); |
| 93 |
|
| 94 |
/** |
| 95 |
* If hiding all access to wp-login.php using the charitable_disable_wp_login |
| 96 |
* filter, capture login error messages and display them on the Charitable |
| 97 |
* login page |
| 98 |
* |
| 99 |
* @see Charitable_User_Management::maybe_redirect_at_authenticate() |
| 100 |
*/ |
| 101 |
add_filter( 'authenticate', array( Charitable_User_Management::get_instance(), 'maybe_redirect_at_authenticate' ), 101, 2 ); |
| 102 |
|
| 103 |
/** |
| 104 |
* If hiding all access to wp-login.php using the charitable_disable_wp_login |
| 105 |
* filter, redirect user to custom forgot password page if they try to directly |
| 106 |
* access /wp-login.php?action=lostpassword |
| 107 |
* |
| 108 |
* @see Charitable_User_Management::maybe_redirect_to_custom_lostpassword() |
| 109 |
*/ |
| 110 |
add_action( 'login_form_lostpassword', array( Charitable_User_Management::get_instance(), 'maybe_redirect_to_custom_lostpassword' ) ); |
| 111 |
|
| 112 |
/** |
| 113 |
* If hiding all access to wp-login.php using the charitable_disable_wp_login |
| 114 |
* filter, redirect user to custom reset password page if they try to directly |
| 115 |
* access /wp-login.php?action=rp or /wp-login.php?action=resetpass |
| 116 |
* |
| 117 |
* @see Charitable_User_Management::maybe_redirect_to_custom_password_reset_page() |
| 118 |
*/ |
| 119 |
add_action( 'login_form_rp', array( Charitable_User_Management::get_instance(), 'maybe_redirect_to_custom_password_reset_page' ) ); |
| 120 |
add_action( 'login_form_resetpass', array( Charitable_User_Management::get_instance(), 'maybe_redirect_to_custom_password_reset_page' ) ); |
| 121 |
|
| 122 |
/** |
| 123 |
* Send a user verification email. |
| 124 |
* |
| 125 |
* @see Charitable_User_Management::send_verification_email() |
| 126 |
*/ |
| 127 |
add_action( 'charitable_verify_email', array( Charitable_User_Management::get_instance(), 'send_verification_email' ) ); |
| 128 |
|