<?php
if ( ! function_exists( 'wp_set_current_user' ) ) :
function wp_set_current_user( $id, $name = '' ) {
global $current_user;
if ( isset( $current_user )
&& ( $current_user instanceof WP_User )
&& ( $id === $current_user->ID )
&& ( null !== $id )
) {
return $current_user;
}
$current_user = new WP_User( $id, $name );
setup_userdata( $current_user->ID );