XF 2.2 Extending batch update user

mcatze

Well-known member
Hi everybody,

for my membermap addon i want to create to options for the batch update users function. It should just clear two fields in the xf_user_profile table.

Can someone give me a hint how to extend the UserAction class for two new actions?

I've tried this at the moment.

PHP:
protected function applyInternalUserChange(\XF\Entity\User $user)
    {
        /** @var \XF\Entity\UserProfile $profile */
        $profile = $user->getRelationOrDefault('Profile', false);
        if ($this->getActionValue('xt_mm_empty_location'))
        {
            $profile->location = '';
            $user->addCascadedSave($profile);
        }
        if ($this->getActionValue('xt_mm_hiding_from_map'))
        {
            $profile->xt_mm_show_on_map = '0';
            $user->addCascadedSave($profile);
        }

        return parent::applyInternalUserChange(\XF\Entity\User $user);
    }
 
Your parent call is slightly wrong though I suspect that would be a PHP parse error anyway.

Otherwise, your logic generally appears to be fine -- it's mimicking the existing code. Have you added the necessary template modifications so your options show up on the batch update page?
 
Top Bottom