PATH:
home
/
lab2454c
/
mact34.com
/
wp-content
/
plugins
/
jetpack
/
json-endpoints
/
jetpack
<?php use Automattic\Jetpack\Constants; class Jetpack_JSON_API_User_Create_Endpoint extends Jetpack_JSON_API_Endpoint { protected $needed_capabilities = 'create_users'; private $user_data; function result() { return $this->create_or_get_user(); } function validate_input( $object ) { $this->user_data = $this->input(); if ( empty( $this->user_data ) ) { return new WP_Error( 'input_error', __( 'user_data is required', 'jetpack' ) ); } if ( ! isset( $this->user_data[ 'email' ] ) ) { return new WP_Error( 'input_error', __( 'user email is required', 'jetpack' ) ); } if ( ! isset( $this->user_data[ 'login' ] ) ) { return new WP_Error( 'input_error', __( 'user login is required', 'jetpack' ) ); } return parent::validate_input( $object ); } function create_or_get_user() { require_once JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php'; // Check for an existing user $user = get_user_by( 'email', $this->user_data['email'] ); $roles = (array) $this->user_data['roles']; $role = array_pop( $roles ); $query_args = $this->query_args(); if ( isset( $query_args['invite_accepted'] ) && $query_args['invite_accepted'] ) { Constants::set_constant( 'JETPACK_INVITE_ACCEPTED', true ); } if ( ! $user ) { // We modify the input here to mimick the same call structure of the update user endpoint. $this->user_data = (object) $this->user_data; $this->user_data->role = $role; $this->user_data->url = isset( $this->user_data->URL ) ? $this->user_data->URL : ''; $this->user_data->display_name = $this->user_data->name; $this->user_data->description = ''; $user = Jetpack_SSO_Helpers::generate_user( $this->user_data ); } if ( is_multisite() ) { add_user_to_blog( get_current_blog_id(), $user->ID, $role ); } if ( ! $user ) { return false; } return $this->get_user( $user->ID ); } public function get_user( $user_id ) { $the_user = $this->get_author( $user_id, true ); if ( $the_user && ! is_wp_error( $the_user ) ) { $userdata = get_userdata( $user_id ); $the_user->roles = ! is_wp_error( $userdata ) ? $userdata->roles : array(); } return $the_user; } }
[-] class.jetpack-json-api-plugins-list-endpoint.php
[edit]
[-] class.jetpack-json-api-user-create-endpoint.php
[edit]
[-] class.jetpack-json-api-modules-list-endpoint.php
[edit]
[-] class-jetpack-json-api-modules-list-v1-2-endpoint.php
[edit]
[-] class-jetpack-json-api-delete-backup-helper-script-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-list-endpoint.php
[edit]
[-] class.jetpack-json-api-modules-modify-endpoint.php
[edit]
[-] class.jetpack-json-api-check-capabilities-endpoint.php
[edit]
[-] class.jetpack-json-api-modules-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-install-endpoint.php
[edit]
[-] class.jetpack-json-api-get-database-object-backup-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-delete-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-modify-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-endpoint.php
[edit]
[+]
..
[-] class.jetpack-json-api-get-post-backup-endpoint.php
[edit]
[-] class.jetpack-json-api-log-endpoint.php
[edit]
[-] class.jetpack-json-api-user-connect-endpoint.php
[edit]
[-] class.jetpack-json-api-core-endpoint.php
[edit]
[-] class.jetpack-json-api-sync-endpoint.php
[edit]
[-] class.wpcom-json-api-get-option-endpoint.php
[edit]
[-] class.jetpack-json-api-get-option-backup-endpoint.php
[edit]
[-] class.jetpack-json-api-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-install-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-get-endpoint.php
[edit]
[-] class.jetpack-json-api-updates-status-endpoint.php
[edit]
[-] class.jetpack-json-api-modules-get-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-modify-v1-2-endpoint.php
[edit]
[-] class.wpcom-json-api-update-option-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-modify-endpoint.php
[edit]
[-] class.jetpack-json-api-get-user-backup-endpoint.php
[edit]
[-] class.jetpack-json-api-core-modify-endpoint.php
[edit]
[-] class.jetpack-json-api-jps-woocommerce-connect-endpoint.php
[edit]
[-] class.jetpack-json-api-translations-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-active-endpoint.php
[edit]
[-] class.jetpack-json-api-get-term-backup-endpoint.php
[edit]
[-] class.jetpack-json-api-cron-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-new-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-delete-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-get-endpoint.php
[edit]
[-] class.jetpack-json-api-plugins-endpoint.php
[edit]
[-] json-api-jetpack-endpoints.php
[edit]
[-] class.jetpack-json-api-translations-modify-endpoint.php
[edit]
[-] class.jetpack-json-api-themes-new-endpoint.php
[edit]
[-] class.jetpack-json-api-maybe-auto-update-endpoint.php
[edit]
[-] class.jetpack-json-api-get-comment-backup-endpoint.php
[edit]
[-] class-jetpack-json-api-install-backup-helper-script-endpoint.php
[edit]