Extension hook not being called?
Posted: 19 February 2009 07:35 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  161
Joined  07-02-2008

Extension hook not being called?

I’ve got two extensions making use of the same hook: member_register_validate_members

With the following activation details respectively:

$DB->query($DB->insert_string('exp_extensions', array(
  
'extension_id' => '',
  
'class'        => get_class($this),
  
'method'       => 'subscribe_member',
  
'hook'         => 'member_register_validate_members',
  
'settings'     => '',
  
'priority'     => 10,
  
'version'      => $this->version,
  
'enabled'      => 'y'
))); 
$hook = array(
    
'extension_id'    => '',
    
'class'           => __CLASS__,
    
'method'          => 'validate_members',
    
'hook'            => 'member_register_validate_members',
    
'settings'        => serialize($settings),
    
'priority'        => 1,
    
'version'         => $this->version,
    
'enabled'         => 'y'
); 

According to the documentation I would expect the validate_members method to be called first as it has a priority of 1, and it does exactly that, but for some reasons the subscribe_member method never get’s called/executed.  I know this because I kill the script right at the top of the method like so:

function subscribe_member($member_id)
{        
  
global $DB;
  die(
"HERE?");

  ... 

But just get presented with the normal “Account Activated” message.

I’m running EE 1.6.6 and can’t upgrade due to numerous core hacks

Any ideas?

Moved to Extensions Technical Support by Moderator

 Signature 

View Creative Agency | http://www.viewcreative.co.uk
Follow us on Twitter! | @viewcreative

Profile
 
 
Posted: 19 February 2009 10:34 AM   [ Ignore ]   [ # 1 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  30388
Joined  04-29-2002

Hi, viewcreative. We have a dedicated forum for extension help. I’m going to move this there for other community members to help.

Profile
MSG
 
 
Posted: 19 February 2009 11:46 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  161
Joined  07-02-2008
Sue Crocker - 19 February 2009 03:34 PM

Hi, viewcreative. We have a dedicated forum for extension help. I’m going to move this there for other community members to help.

Thanks Sue - yes I am aware of that, I’ve made numerous posts to the extension forum and received almost no replies! It seems only to be ever frequented by community members who (and why should they) rarely offer any assistance - which can be rather frustrating.

I posted it to the Technical Support forum in the vain hope that it might be picked up (which it has) and dealt with by a member of the EE development team (which it hasn’t! just moved to a forum where it’ll never be answered!)

If there is anyone out there…

I have tried disabling the other extension and the hook gets called. Any ideas why it doesn’t get called. I was under the impression that multiple hooks / multiple extensions were supported, and were managed by priority.  Any idea what I’m doing wrong?

 Signature 

View Creative Agency | http://www.viewcreative.co.uk
Follow us on Twitter! | @viewcreative

Profile
 
 
Posted: 19 February 2009 12:38 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

Thanks Sue - yes I am aware of that, I’ve made numerous posts to the extension forum and received almost no replies! It seems only to be ever frequented by community members who (and why should they) rarely offer any assistance - which can be rather frustrating.

Our development team is very small, and while we try to pop in to these forums occasionally, we’d never get any work done if we answered every question posted about writing add-ons for ExpressionEngine.  We’re hoping to increase this interaction when we aren’t so fully buried in working on 2.0.  As to why should community members help one another?  The ones that do would tell you that both offering and receiving help from other third parties is extremely helpful both to their skill, their involvement in this cottage industry, and the success of their business.

As for not receiving answers, particularly when you’re talking about troubleshooting someone else’s code, how the questions are framed plays a large role.  Someone coming along to help you will be asking in their head “how much am I going to be on the hook for if I reply to this person’s question?”.  Is it clear from the question that this person has read the developer documentation?  Do they have a solid understanding of PHP?  Does the information that they have shared demonstrate that they know what’s relevant?  Between “can’t upgrade due to numerous core hacks” and not showing your method’s code, the possibilities are near endless - more information would make people more inclined to assist.

I’ll take a stab at it based on what you’ve stated.  First make sure that error reporting is enabled in your installation and your PHP environment.  Next check your exp_extensions table to make sure that both methods were properly added to the database on activation, and that there are not other extensions that also utilize this hook that might interfere.  Lastly, keep both hooks registered, but remove all of the code from your first method that is being called, to rule out an issue with the code being executed in that method.  If none of those lead you to discover the issue, I’d suggest zipping your extension and posting it as an attachment so someone can look at your code.

 Signature 
Profile
MSG
 
 
Posted: 23 February 2009 06:06 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  11303
Joined  06-03-2002

Any conclusions or need some additional help, viewcreative?

 Signature 
Profile
MSG