I am attempting to make an environment out of the command given in one of the answers to this question: Customizing theorem name.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\newenvironment{namedtheorem}[1]{
\theoremstyle{definition}
\newtheorem*{thmTemp}{#1}
\begin{thmTemp}}{\end{thmTemp}}
\begin{document}
\begin{namedtheorem}{foo}
This is a named theorem bar.
\end{namedtheorem}
\begin{namedtheorem}{bar}
This is a named theorem bar.
\end{namedtheorem}
\end{document}
Unfortunately, my invocation of \newtheorem*{thmTemp}{#1} seems to be scoping beyond the current environment, causing an error when the environment is used a second time.
How can I fix my environment to avoid this problem?

\renewtheoremfrom thentheorempackage. – Peter Grill Mar 18 '13 at 06:19