1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Additional userfields + edit user acp form

Discussion in 'XenForo Development Discussions' started by ragtek, Jul 15, 2011.

  1. ragtek

    ragtek Guest

    I have a add-on which adds own fields to the edit user acp form.

    I've created a own proxycontroller exstending the controlleradmin_user to extend the actionSave()

    If i edit an existing user, it's working fine.
    BUT if i create a new user, the userid is missing and my own method can't access the new userId to be able to save the add-on related userfields.

    PHP:
    public function actionSave()
        {
            
    $return parent::actionSave();
            
    #die(print_r($return));
            
    $userId $this->_input->filterSingle('user_id'XenForo_Input::UINT);
    ....
    ...
    return 
    $this->responseRedirect(
                
    XenForo_ControllerResponse_Redirect::SUCCESS,
                
    XenForo_Link::buildAdminLink('users/search'null, array('last_user_id' => $userId)) . $this->getLastHash($userId)
            );

    Is it possible to get the userId in my method?
    I way would be to overwrite the method completly with my own, but that's imho unneccessary and a little bit dirty because i would need to change this, everytime when the original method was changed to AND if every add-on would do this, it wouldn't work because every method would try to do the same (from the original method) + then the own stuff.

    I checked the return from the parent method and i saw that i could MAYBE use the redirectTarget to extract the userid
    [redirectTarget] => admin.php?users/search&last_user_id=140#_140

    but is there any better way for this?

    PS:

    Problem is related to http://xenforo.com/community/threads/additional-thread-fields.17373/ and all other forms with an redirect^^

    Here's my example code: http://ragtek.org/xenforo/threads/d...etting-invites-in-user-profile.266/#post-1090

    The same problem exists with pages and own fields.

    we had to overwrite the COMPLETE actionSave method, copy the copy the code into my method and add the 2 new fields... (ugly c&p code)
    http://xenforo.com/community/threads/additional-data-saving.16254/
     
  2. ragtek

    ragtek Guest

  3. ragtek

    ragtek Guest

    I've found this workaround
    PHP:

    class Ragtek_Invite_ControllerAdmin_User extends

        
    XFCP_Ragtek_Invite_ControllerAdmin_User
    {
        public function 
    actionSave()
        {
            
    $return parent::actionSave();
            
    $target $return->redirectTarget;

            
    $pattern '/(?P<foo>\w+)#_(?P<userid>\d+)/';
            
    preg_match($pattern$target$matches);

            
    $userId $matches['userid'];



            if (
    Ragtek_Invite_Helper::canAdmin() AND $userId != 0) {
                
    $this->_assertPostOnly();

                if (
    $userId) {
                    
    $user $this->_getUserOrError($userId);
                    
    $this->getHelper('Admin')->checkSuperAdminEdit($user);
                }
     
    Fuhrmann likes this.

Share This Page