Simplifying the if else statement
What you have is essentially:

if (a) {
   if (b) c();
   d();
}
else if (b) e();


Where:

a = user_ptr
b = batchOrTimestamp != "batch"
c = user_ptr-&gt;ping();
d = 2 lines, starting with `AttributeMap::GuardSPtr guard = user_ptr-&gt;m_attrMap.get_guard();`
e = 3 lines, starting with `user_ptr = User::MakeUser(user_id);`


One way to rewrite this is:

if (a &amp;&amp; b) c();
if (a) d();
else if (b) e();


And another way is:

if (b) {
   if (a) c();
   else e();
}
if (a) d();


Which of these ways you prefer is up to you. The problem is that you have a total of three branches. One for a, one for b &amp;&amp; !a and one for a &amp;&amp; b.

I don't believe it's possible to simplify this in a better way (I would gladly be proven wrong).