Hot answers tagged

10

Yes. For example.... $hooks = array( "template_fetch_template" => "template_fetch_template", "typography_parse_type_end" => "typography_parse_type_end" ); foreach ($hooks as $hook => $method) { $data = array( 'class' => __CLASS__, 'method' => $method, 'hook' => $hook, ...


9

Yip. You're looking for: ee()->session->userdata('member_id'); It's in the session class: http://ellislab.com/expressionengine/user-guide/development/usage/session.html


5

I got it working.... silly, silly, silly me.... Initially I used entry_submission_end($entry_id, $meta, $data), but realised I needed entry_submission_ready. I overlooked the fact entry_submission_ready uses different arguments, its ($meta, $data, $autosave) and not ($entry_id, $meta, $data)! Now it works fine with the correct arguments. RTFM!


5

This was driving me insane but I've figured it out. You need to edit the $entry object (1st parameter of the function) in order for this to work. You can, however, use the 2nd parameter, $values, for easy reading of the data. public function before_channel_entry_save( $entry, $values ) { // Set value for specific field name $entry->setProperty( '...


4

Something is way off about your approach. You should not need the ob_start() methods if you were to build this properly. If you need a callback method, what you really want to look into is a using a module for a "controller". (For more info on a controller, refer to CodeIgniter's MVC pattern.) So could create an ACT url (http://yourdomain.com/ACT=X) and ...


4

That hook gives you all the data you need to query the database. $meta will hold your entry_id, channel_id, title, etc (anything that goes in exp_channel_titles), and $data holds your custom field data. So just as an example: if(!empty($meta['entry_id'])) { $current = $this->EE->db->query(" SELECT * FROM exp_channel_data WHERE entry_id ...


4

It mainly goes down to processing order. When the order is successfully placed Store then does a little housekeeping to round off the order completion process. It will look to set a default status before checking for any extensions latching on to the store_order_complete_end hook. So walking through the process with your specific extension code: Order is ...


3

It looks like there is a problem with the logic in your extension. You don't want to change the name of a particular status when the order is complete - you want to change the status of the order. I would expect it to look something more like this: public function store_order_complete_end($order) { if (ee()->session->userdata('group_id') == 10) ...


3

It looks like the hooks were running, but it was more a case of the logged messages not appearing. Store uses the Post-Redirect-Get pattern, which means that the cart is updated (and hooks run) during an HTTP POST request. When the cart has finished updating (unless there were any errors), it redirects the customer's browser back to the checkout page using ...


3

After tinkering around, I found out that the way to do it is to set these values inside the method $this->EE->api_channel_entries->data['my_field_id'] = 'my_field_value';


3

Yes I don't see any problem with that if it's just for a simple tax adjustment. We don't look to make things deliberately hard. :) You could also look to set it up as an actual tax adjustment if you wanted to however. Adjustments were introduced in Store v2 to handle extra line items for anything which is not a product (e.g. shipping, discounts, taxes). ...


3

It depends on whether the events that trigger the functions trigger a hook. If a button click, form submission, page load etc triggers a hook, then an extension is the right place for your custom functionality. If no hook is triggered and you need to respond to arbitrary clicks or form submissions, then a module or plugin would be appropriate. You can react ...


3

Extensions are for backend or server side stuff, whereas Modules can interact via the frontend or EE Control Panel. So an Extension captures a hook from another class, but can't capture a form submission or Ajax call from the frontend. Whereas a Module can't tap into a hook. But you can roll both an extension and a module into a single add-on (same name, ...


2

If you look at Activating & Updating in the Extensions documentation, you'll see in the code example that the data passed to the Insert query contains a reference to an ExpressionEngine hook. That database entry will enable your extension to be called when that hook is triggered. All available hooks are documented here.


2

Yes, it can be a bit tricky to get into it at first. What you're looking for are the Extension docs: http://ellislab.com/expressionengine/user-guide/development/extensions.html An extension can be included alongside a module. The code that you posted is the actual code called within EE when loading any extensions attached to that hook. Thus all the ...


2

I just want to point out that BrilliantRetail has methods for handling IPN callbacks when creating custom gateways. I would consider using the core methods instead of putting logic in templates or files outside of the ExpressionEngine system: http://docs.brilliantretail.com/3-extending-brilliantretail/payment-gateways/index.html#ipn-methods The PayPal ...


2

First - you can get this count in your template by using {my_matrix_field:total_rows} - but I'll assume you need the number stored as a value in a field for other purposes (use in orderby perhaps). In which case - yes, you'd write an extension, and use the entry_submission_ready hook. Then in your method, pass $data by reference, so you can modify it. ...


2

You should look into "URI Class"


2

No, there isn't any hook for it. You might see this question/answer Track logged-in user events which seems much similar to your need.


2

I usually check if entry_id = 0 (for new entry) $this->EE->input->get_post('entry_id') == 0


2

You can compare $meta['edit_date'] with $meta['entry_date']. You will need to bring both dates to same format of course, as entry_date contains current timestamp, while edit_date is formatted as '%Y%m%d%H%i%s'


2

This is likely because the comment notification uses not the database entry for the comment, but the POSTed comment data. The insert_comment_insert_array hook only affects what gets inserted into the database.


2

As Derek said, there isn't a hook for member group change, but you could accomplish this by using the two member update hooks provided by the Member Model in conjunction with the Cache Access provided by the Session Class. Hook 1: member_update_start In your method called by this hook store the member's existing group_id using the Session Class set_cache() ...


2

I have got it to work using a second hook, channel_form_submit_entry_start Using channel_form_submit_entry_start I can manipulate the $_POST array directly, then this saves. Seems wrong I should manipulate $_POST, and also a shame I have to have a second method to do the same as the entry_submission_ready (difficult to combine as I am using different arrays)...


2

You might use sessions_start hook and set language config variable within hooked function.


2

There are no ExpressionEngine hooks for the forgot password feature but given that you intention is to override the email being sent when a user forgets their password you mainly just need to change that template. The default styling can be changed in: Design > Message Pages > Email Notifications. Alternatively Postmaster provides a nice abstraction to ...


2

I think either method would work. The hook is going to be the more nerdy (read "hard") way to do it. I use the store_order_complete_end hook to trigger code that notifies other systems of the order. Depend ing on how AJW Export is written, you may be able to fire it off from your code in the extension. The easier approach would be to do it in the template. ...


2

I recently made an extension to do this, so I've put it up on GitHub for others to learn from. https://github.com/expressodev/store_order_export Generally, you want to use the store_order_complete_end hook, which runs when an order is marked as "complete" (when payment is successful). From there it is easy to write an extension which generates any XML (or ...


2

To use the store_order_taxes hook correctly, you should append a Store\Model\Tax object to the list of existing taxes. That way, Store will automatically make all the necessary adjustments to the order totals for you (you shouldn't need to edit the order directly). If you change the $order->order_tax and $order->order_total variables directly, you may ...


2

You might find the EE Extension Development guide useful. Basically, you need to create an extension which handles the store_order_complete_end hook. I'm not sure what you mean by the $data parameter, but the $order parameter is a Store Order model. You can access attributes on it like this: $order->id; $order->billing_address; $order->order_total;...


Only top voted, non community-wiki answers of a minimum length are eligible