We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Weird extension hook (submit_new_entry_end) behavior

Development and Programming

Tiger0516's avatar
Tiger0516
31 posts
17 years ago
Tiger0516's avatar Tiger0516

I am trying to write an extension that does some custom job based of the status of an entry after submitting the entry in CP. I use submit_new_entry_end hook. It works well in one EE site but does not in another EE site.

Problem:

Instead of doing what I want to do after entry form submission, it does the job when the form is loaded (when I click the entry to edit it).

I have made some changes to EE but I change nothing in cp.publish, where submit_new_entry_end is in.

I also find the site that has problem has another extension that also extends this hook. Will it be the issue? But even I disable the other extension, my extension still works in this weird way in this site.

Any idea?

Thanks!

Code:

<?php

if ( ! defined('EXT')) {
    exit('Invalid file request'); }

class Change_author {
    
    var $setting=array();
    var $name            = 'Change author';
    var $version         = '1.0.0';
    var $description     = 'Change author based on status';
    var $settings_exist  = 'n';
    var $docs_url        = '';
    
    function Change_author ($setting='') {
        
        $this->setting=$setting;    
    } 
    
    function changeAuthor($data)
    {
    if (isset($_GET))
        {
            $a=print_r($_GET,true);
            echo "<pre>$a</pre>

<p>”;
        }
        if (isset($_POST))
        {
            $a=print_r($_POST,true);
            echo “</p>

<pre>$a</pre>

<p>”;
        }
        $EXT->end_script = TRUE;
    }</p>

<pre><code>function activate_extension()
{
    global $DB;

$DB->query($DB->insert_string('exp_extensions',
          array(
                'extension_id' => '',
                'class'        => "Change_author",
                'method'       => "changeAuthor",
                'hook'         => "submit_new_entry_end",
                'settings'     => "",
                'priority'     => 5,
                'version'      => $this->version,
                'enabled'      => "y"
              )
                             )
          );
}

}

?></pre>

[Mod Edit: Moved to the extensions development forum as it is more appropriate]

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Yes, please refer to the documentation on multiple extensions on the same hook. Any other differences would be a result only of differences in your code and your modifications between the two sites.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.