PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.2.2
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.2.2
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Controllers / Rest / CheckEmailController.php
CheckEmailController.php
40 lines 1014 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Controllers\Rest;
4
5 /**
6 * Handle check email requests through the REST API
7 */
8 class CheckEmailController extends RestController {
9 /**
10 * Check login.
11 *
12 * @param \WP_REST_Request $request The REST request.
13 *
14 * @return true|\WP_Error
15 */
16 public function checkEmail( \WP_REST_Request $request ) {
17 $login = $request->get_param( 'login' ) ?? '';
18 // handle email.
19 if ( strpos( $login, '@' ) !== false ) {
20 $user = get_user_by( 'email', $login );
21 return $user ? true : new \WP_Error(
22 'invalid_email',
23 __( 'There is no account with that username or email address.', 'surecart' )
24 );
25 }
26
27 // check for login.
28 $user = get_user_by( 'login', $login );
29
30 return $user ? true : new \WP_Error(
31 'invalid_username',
32 sprintf(
33 /* translators: %s: User name. */
34 __( 'The username <strong>%s</strong> is not registered on this site. If you are unsure of your username, try your email address instead.', 'surecart' ),
35 esc_html( $login )
36 )
37 );
38 }
39 }
40