Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 0.7.9.5, action, cn_post_process_$action-entry
- This topic has 5 replies, 2 voices, and was last updated 8 years, 8 months ago by
Steven Zahm.
-
AuthorPosts
-
04/04/2014 at 4:43 pm #284364
Michael
ParticipantI’m currently building a connector plugin so that any entry that has geocode will get added to WP Google Maps. One thing I need, however, is the categories of each entry on update. I’m currently using the hook “cn_post_process_…” on class.entry-actions.php. Above the action, it updates the categories, but it doesn’t update the $entry variable. The result is that the entry being passed to the action has the previous category settings, instead of the current ones.
Do you think you could update the plugin to update the entry prior to doing the action so it has the latest categories? Or is there another way that I should be using? I’m using $entry->getCategory()
04/04/2014 at 5:25 pm #284365Steven Zahm
Keymaster@ Michael
Yeah, I see the issue. Can you try something for me? Add the following right before the action in
class.entry-actions.php
:$entry->set( $entryID );
That should refresh the entry object with up to date data.
Let me know and I’ll ad the change so it is included in the next update.
04/07/2014 at 9:28 am #287937Michael
ParticipantThat did the trick.
04/07/2014 at 10:42 am #287947Steven Zahm
Keymaster@ Michael
Great to hear! I just added it to the change so it’ll be in the next update.
09/24/2014 at 1:50 pm #305045Michael
ParticipantLooks like this is an issue again.
So I have a hook that adds an action to cn_post_process_update-entry
In the middle of the function it links to I have this code:
<
pre>
public static function saveMarker( $entry, $update = false ) {
global $connections, $wp_rewrite, $wpdb;
$entryID = (int) $entry->getId();
$entry->set( $entryID );echo "<pre>"; print_r( $_POST ); print_r( $connections->retrieve->entryCategories( $entryID ) ); var_dump($entry); $categories = $entry->getCategory(); print_r($categories); die(); ...
}
The following is what I get. Note the Post info is different from what I get with all the rest. It was working, but now it’s showing the old category information again, unless I update the entry twice.
// _POST Array ( [cn-action] => update_entry [update] => Update [entry_category] => Array ( [0] => 9 // Category set to 9 and 10 [1] => 10 ) ... // Output of entryCategories Array ( [0] => stdClass Object ( [term_id] => 11 // still says 11, not 9 and 10 [name] => Markets [term_taxonomy_id] => 11 [taxonomy] => category ... ) ) object(cnEntry)#62 (52) { ["id":"cnEntry":private]=> int(3) ["categories":"cnEntry":private]=> array(1) { [0]=> object(stdClass)#60 (9) { ["term_id"]=> string(2) "11" ["name"]=> string(7) "Markets" ... // $entry->getCategory(); is the same as above.
I think I know the issue. Within the class.retrieve.php, the function entryCategories: you are checking for a cache of the sql to be run. It must have already run previously and then the record is updated. At the time of the hook, I’m now getting the cached results, not the new results. I think I can come up with a hack that should work in the meantime. But if anyone is using hooks, this will need to be addressed.
I’d suggest that when you store the results and the SQL, also include a list of tables. When an update occurs, scan the cached list for the tables that were affected and remove the cached results that used those tables. This would ensure that on an update, the code will always fetch fresh results instead of cached ones.
09/25/2014 at 10:33 am #305150Steven Zahm
Keymaster@ Michael
Dang! Yes that ad hoc caching I’m doing would cause a problem with getting the updated categories. It is really just a temp solution until I have the cnCache class completely fleshed out.
Until I sort this out, maybe you could just query the categories in your filter instead…
$sql = $wpdb->prepare( "SELECT t.*, tt.* FROM " . CN_TERMS_TABLE . " AS t INNER JOIN " . CN_TERM_TAXONOMY_TABLE . " AS tt ON t.term_id = tt.term_id INNER JOIN " . CN_TERM_RELATIONSHIP_TABLE . " AS tr ON tt.term_taxonomy_id = tr.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tr.entry_id = %d ", $entry->getId() ); $categories = $wpdb->get_results( $sql );
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.