bjeremymoss
Forum Replies Created
-
BEAUTIFUL! It looks like it works thus far! I’ll have to put it through a little more testing on the server but it looks like it works great!
Thanks for the Help!!!
BAH!!! that’s right… I should have thought of that… by the time the publish function runs I should have the global $post var so I can setup all my actions for every type then decide inside the publish function if the email should actually send or not.
The only issue with that is is that they won’t be able to use future_to_publish on news posts in other categories… I tried getting the post category from the ID to detect which set of actions to apply but it didn’t work… I may have to bite the bullet and tell them not to use publish settings on news items and only on evens unless they want to change even systems from their old school method.
FYI here’s the code I tried. It’s pretty simple!
// check for the $post ID $id = $_GET['post']; // echo 'the post ID = '.$id; $isEvents = false; if($id){ // Have post ID lets get the categories $categories = get_the_category($id); if($categories){ foreach($categories as $category){ echo 'category = '.$category->slug; if($category->slug == 'events'){ $isEvents = true; } } }; } // If this is a Future Event Category if($isEvents){ // if it is a future event set actions for going to scheduled post. add_action('new_to_future', array(&$this, 'publish')); add_action('draft_to_future', array(&$this, 'publish')); add_action('auto-draft_to_future', array(&$this, 'publish')); add_action('pending_to_future', array(&$this, 'publish')); }else{ // if it not an event go the nomral route. add_action('new_to_publish', array(&$this, 'publish')); add_action('draft_to_publish', array(&$this, 'publish')); add_action('auto-draft_to_publish', array(&$this, 'publish')); add_action('pending_to_publish', array(&$this, 'publish')); add_action('private_to_publish', array(&$this, 'publish')); add_action('future_to_publish', array(&$this, 'publish')); if ( $this->subscribe2_options['private'] == 'yes' ) { add_action('new_to_private', array(&$this, 'publish')); add_action('draft_to_private', array(&$this, 'publish')); add_action('auto-draft_to_private', array(&$this, 'publish')); add_action('pending_to_private', array(&$this, 'publish')); } };
Well I’m finally getting a chance to try this and it works but it also means that the regular ones won’t work on publish… cause I take those out for events… I’m trying to think of way to trigger difference add_action() elements based on what category is chosen but I think I’m hitting a brick wall… anyone with any ideas?
For Clarification yes you are correct they want the notification to send when the the post is scheduled not when it publishes itself.
Of course! I hadn’t thought of using the post status transitions which of course you have set in the core to call the publish function.
Now all I have to do is add those hooks (THANKS!) and put in a check to see if the post is in the correct category.
For anyone after me wanting to know about Post Status Transitions
and to add the actions mattyrob mentions above I’m assuming they start at line 1698 of class-s2-core.php (at least in version 8.9.1 of the plugin) and would look like
add_action('new_to_future', array(&$this, 'publish'));
and so on.Thanks again mattyrob!
Works great thanks Vasyl!!!
Like Brian I am now having issues setting users to anything but subscriber with WordPress 3.2.1 and Access Manager 1.4.3