Automattic\WooCommerce\Admin\API
OnboardingProfile::get_email_prefill()
Returns a default email to be pre-filled in OBW. Prioritizes Jetpack if connected, otherwise will default to WordPress general settings.
Method of the class: OnboardingProfile{}
No Hooks.
Return
WP_Error|WP_REST_Response
.
Usage
$OnboardingProfile = new OnboardingProfile(); $OnboardingProfile->get_email_prefill( $request );
- $request(WP_REST_Request) (required)
- Request data.
OnboardingProfile::get_email_prefill() OnboardingProfile::get email prefill code WC 9.7.1
public function get_email_prefill( $request ) { $result = array( 'email' => '', ); // Attempt to get email from Jetpack. if ( class_exists( Jetpack_Connection_Manager::class ) ) { $jetpack_connection_manager = new Jetpack_Connection_Manager(); if ( $jetpack_connection_manager->is_active() ) { $jetpack_user = $jetpack_connection_manager->get_connected_user_data(); $result['email'] = $jetpack_user['email']; } } // Attempt to get email from WordPress general settings. if ( empty( $result['email'] ) ) { $result['email'] = get_option( 'admin_email' ); } return rest_ensure_response( $result ); }