src/Import_Command.php
private function create_authors_for_mapping( $author_data ) {

		$author_mapping = array();
		foreach ( $author_data as $author ) {

			if ( isset( $author->user_email ) ) {
				$user = get_user_by( 'email', $author->user_email );
				if ( $user instanceof WP_User ) {
					$author_mapping[] = array(
						'old_user_login' => $author->user_login,
						'new_user_login' => $user->user_login,
					);
					continue;
				}
			}

			$user = get_user_by( 'login', $author->user_login );
			if ( $user instanceof WP_User ) {
				$author_mapping[] = array(
					'old_user_login' => $author->user_login,
					'new_user_login' => $user->user_login,
				);
				continue;
			}

			$user = array(
				'user_login' => '',
				'user_email' => '',
				'user_pass'  => wp_generate_password(),
			);
			$user = array_merge( $user, (array) $author );

			$user_id = wp_insert_user( $user );
			if ( is_wp_error( $user_id ) ) {
				return $user_id;
			}

			$user             = get_user_by( 'id', $user_id );
			$author_mapping[] = array(
				'old_user_login' => $author->user_login,
				'new_user_login' => $user->user_login,
			);
		}
		return $author_mapping;

	}
private function create_authors_for_mapping( $author_data ) {

		$author_mapping = array();
		foreach ( $author_data as $author ) {

			if ( isset( $author->user_email ) ) {
				$user = get_user_by( 'email', $author->user_email );
				if ( $user instanceof WP_User ) {
					$author_mapping[] = array(
						'old_user_login' => $author->user_login,
						'new_user_login' => $user->user_login,
					);
					continue;
				}
			}

			$user = get_user_by( 'login', $author->user_login );
			if ( $user instanceof WP_User ) {
				$author_mapping[] = array(
					'old_user_login' => $author->user_login,
					'new_user_login' => $user->user_login,
				);
				continue;
			}

			$user = array(
				'user_login' => '',
				'user_email' => '',
				'user_pass'  => wp_generate_password(),
			);
			$user = array_merge( $user, (array) $author );

			$user_id = wp_insert_user( $user );
			if ( is_wp_error( $user_id ) ) {
				return $user_id;
			}

			$user             = get_user_by( 'id', $user_id );
			$author_mapping[] = array(
				'old_user_login' => $author->user_login,
				'new_user_login' => $user->user_login,
			);
		}
		return $author_mapping;

	}
private function create_authors_for_mapping ( $ author_data ) { $ author_mapping = array ( ) ; foreach ( $ author_data as $ author ) { if ( isset ( $ author -> user_email ) ) { $ user = get_user_by ( 'email' , $ author -> user_email ) ; if ( $ user instanceof WP_User ) { $ author_mapping [ ] = array ( 'old_user_login' => $ author -> user_login , 'new_user_login' => $ user -> user_login , ) ; continue ; } } $ user = get_user_by ( 'login' , $ author -> user_login ) ; if ( $ user instanceof WP_User ) { $ author_mapping [ ] = array ( 'old_user_login' => $ author -> user_login , 'new_user_login' => $ user -> user_login , ) ; continue ; } $ user = array ( 'user_login' => '' , 'user_email' => '' , 'user_pass' => wp_generate_password ( ) , ) ; $ user = array_merge ( $ user , ( array ) $ author ) ; $ user_id = wp_insert_user ( $ user ) ; if ( is_wp_error ( $ user_id ) ) { return $ user_id ; } $ user = get_user_by ( 'id' , $ user_id ) ; $ author_mapping [ ] = array ( 'old_user_login' => $ author -> user_login , 'new_user_login' => $ user -> user_login , ) ; } return $ author_mapping ; }
Creates users if they don't exist, and build an author mapping file.
Creates users if they don t exist and build an author mapping file .