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]
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.