If you want to perform string substitutions it is better to use \getrefnumber from the refcount package instead of \ref. It is an expandable version of \ref that can be used for things like string substitutions.
Some of the answers to the question you linked to still might not work out of the box with \getrefnumber though if they do not first expand their arguments (and thus perform substitutions on \getrefnumber{sec:section11} instead of the on 1.1).
Here is a possible solution that uses the xstring package.
I don't know precisely by what procedure 1.1 is supposed to be transformed into 0011, so this probably doesn't precisely do what you want.
\documentclass{article}
\usepackage{refcount}
% \usepackage{hyperref} %% Optional
%% N.B. refcount is automatically loaded by hyperref, so you don't need both
\usepackage{xstring} %% Package for string manipulation
\DeclareRobustCommand*\myref[1]{\formatsectionnumber{\getrefnumber{#1}}}
\newcommand*\formatsectionnumber[1]{%
\begingroup
%% Prepend and append two 0's, perform the substitution and store the result in \temp:
\StrSubstitute[0]{00#100}{.}{}[\temp]%
%% Store the first four characters in \temp:
\StrLeft{\temp}{4}[\temp]%
%% Print the result
\temp
\endgroup
}
\begin{document}
\section{Section 1}\label{sec:section1}
\subsection{Section 1.1}\label{sec:section11}
Section~\myref{sec:section1} has a subsection which we will call \myref{sec:section11}.
\end{document}

hyperrefpackage documentation ? – BambOo Apr 04 '18 at 17:13