If member publish entry I want publish some info to another channel I wrote extension, but it doesn't work and always I see 'An Error Occurred Creating the Entry' I need help

This is my code

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Calladder_ext {

    public $name           = 'Call adder';
    public $version        = '1.0';
    public $description    = 'Add call when publish to channel';
    public $settings_exist = 'n';
    public $docs_url       = '';

    private $settings = array();

     * Constructor
    public function __construct($settings='')
        $this->EE =& get_instance();

    public function add_call($entry_id, $meta, $data)
        if( in_array( $data['channel_id'], array(4,5,6) ) )
            //prepare data
            // some code...

            $datap = array(
                    'title'         => $title,
                    'channel_id'    => 7,
                    'field_id_48'   => $phone,
                    'field_id_47'   => $name,
                    'field_id_50'   => $email,
                    'field_id_49'   => $comment,
                    'field_id_88'   => $entry_id

            $this->insert_entry(7, $datap);



    private function insert_entry($channel_id, $data)

        $this->EE->api_channel_fields->setup_entry_settings($channel_id, $data);

        if ($this->EE->api_channel_entries->submit_new_entry($channel_id, $data) === FALSE)
                show_error('An Error Occurred Creating the Entry');

    public function activate_extension()

        $data = array(
            'class'     => __CLASS__,
            'method'    => 'add_call',
            'hook'      => 'entry_submission_end',
            'settings'  => serialize($this->settings),
            'priority'  => 2,
            'version'   => $this->version,
            'enabled'   => 'y'

        $this->EE->db->insert('extensions', $data);


    public function disable_extension()
        $this->EE->db->where('class', __CLASS__);
  • Does it create the original entry? And does it get called multiple times? (does storing new entry with api call same hook again?).
    – GDmac
    Feb 22 '13 at 7:59
  • Please consider rewriting your question so that it contains more than 1 sentence and a dump of your entire file. Explain what hooks you are using, what you have tried so far, and what you think might be going wrong. Feb 22 '13 at 8:07
  • Thank. ANd how I can add category?
    – websecret
    Feb 27 '13 at 19:26

Chances are you're missing a required field in that channel, or submitting some incorrect data. To find out why your entry is not being submitted, add this within your "if submit_new_entry is false" conditional:

print($this->EE->api_channel_entries->errors); exit();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.