The Friendly Web Guys

The Jimmyweb Blog

Symfony Tip: Admin Generator + sfGuardPlugin + SfGuard Profile

5th
August

2009

Posted by James Beattie - under News 1 Comment

tip

If you get the error “Call to undefined method BasesfGuardUser::addsfGuardUserProfile” when using a custom sfGuardUser profile, you need to add the following method to the file /plugins/sfGuardPlugin/lib/model/sfGuardUser.php

  public function addsfGuardUserProfile()
  {
    if(!$profile = $this->getProfile())
    {
      $profile = new sfGuardUserProfile;
      $profile->setUserId($this->getId());
    }
    return $profile;
  }

I know it sucks to hack a core plugin file, but sometimes we must pragmatic!

Tags used in this post:
,

Share this post:
Share Share Share Share Share

One Comment

gravatar

Jeffrey says:

February 11th, 2010

I saw the error comes from plugin core file, thinking that might be an older version of sfGuardPlugin.

After some struggling and setback, find the solution here.

Jimmyweb, Hallelujah!

(Funny, why the plugin has to been hacked to behave in the way it should be. Maybe we don’t have to do it in Symfony 1.4, with sfGuardPlugin v4.0.0)

Leave a Comment