WP_Importer::set_user() WordPress Method

The WP_Importer::set_user() method allows you to set the current user during an import. This is useful if you want to import data from another user into the current user's account.

WP_Importer::set_user( int $user_id ) #


Parameters

$user_id

(int)(Required)


Top ↑

Return

(int|void)


Top ↑

Source

File: wp-admin/includes/class-wp-importer.php

	public function set_user( $user_id ) {
		if ( is_numeric( $user_id ) ) {
			$user_id = (int) $user_id;
		} else {
			$user_id = (int) username_exists( $user_id );
		}

		if ( ! $user_id || ! wp_set_current_user( $user_id ) ) {
			fwrite( STDERR, "Error: can not find user\n" );
			exit;
		}

		return $user_id;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.