//------------------------------------------------------------------------------------------------------- // Function: Manage User Sync between Wordpress and Gallery2 // Parameters: Wordpress User ID // Returns: G2 Return Code //------------------------------------------------------------------------------------------------------- function g2_manage_wpg2user($user_ID) { global $g2_option; // Call WP<->G2 User Syncing if ($g2_option['g2_createusers'] == "Yes") g2_sync_userbase(); // If G2 User not active then link or create. $ret = GalleryEmbed::checkActiveUser($user_ID); if ($ret->isError()) { // Always find the G2 User if it has been manually created $userdata = get_userdata($user_ID); list ($ret, $g2finduser ) = GalleryCoreApi::fetchUserByUsername ($userdata->user_login); if (!$ret->isError()) { GalleryEmbed::addExternalIdMapEntry($user_ID, $g2finduser->_id, 'GalleryUser'); // Set WP/G2 User Active $ret = GalleryEmbed::checkActiveUser($user_ID); } else { GalleryEmbed::checkActiveUser(''); } } return $ret; }