ID, 'download_file', true); /* EG 'http://server.example.com/download' */ $download_url = get_post_meta($post->ID, 'download_url', true); /* EG URL where redirected if no username exists */ $download_error = get_post_meta($post->ID, 'download_error', true); if ($download_file && $download_url) { global $current_user; get_currentuserinfo(); wp_redirect(ambdownload::getDownloadLink($current_user->user_email, $download_url, $download_error, $download_file)); exit; } } } } add_action( 'template_redirect', array('ambdownload', 'downloadRedirect'), 1, 2);