An implementation using environ
:

\documentclass{article}
\usepackage{environ}
\makeatletter
\newcommand{\@afterminipage}{}
\newcommand{\afterminipage}[1]{\xdef\@afterminipage{\@afterminipage#1}}
\let\oldminipage\minipage
\let\endoldminipage\endminipage
\newsavebox{\minipagesavebox}
\RenewEnviron{minipage}[2][c]{%
\savebox{\minipagesavebox}{\BODY}%
\let\afterminipage\@gobble
\begin{oldminipage}[#1]{#2}
\BODY
\end{oldminipage}
\@afterminipage
\gdef\@afterminipage{}%
}
\makeatother
\begin{document}
\begin{minipage}{.5\textwidth}
Something.
\afterminipage{abc}%
def
\end{minipage}
\begin{minipage}[b]{.5\textwidth}
Something
\afterminipage{multiple }%
completely different here that should span multiple lines of
\afterminipage{lines}%
code
\afterminipage{ of code.}%
\end{minipage}
\end{document}
One problem with this approach is a dual processing of the contents of the minipage
environment. The first time only the contents provided by \afterminipage
s are added together, with everything else captured in a box that is never set. The second time, the box is set with the contents. This could be modified to just set the already-captured contents, if need be.
minipage
environment. It'll be floating to somewhere different.