A unique wp_schedule_single_event() for each post?

You can pass arguments to the wp_schedule_single_event function: wp_schedule_single_event($newdate, “one_day_before_event”, array($post->ID)); Then if you do an add_action you can say how many arguments it will receive (in this case 1). add_action( ‘one_day_before_event’, ‘some_function’, 10, 1 ); Then in your function you can access the variable: function some_function($post_id) { // Do something with $post_id }

add_action hook for publish_post not working

When a post is published/saved, it does not do it in a single script execution. It redirects to a different script, does the save, then redirects back to where you started. If you want to confirm that your hook is working, use update_option(), and delete the option immediately after displaying it so it’s not latent … Read more

Running a wordpress action when a custom post type term (taxonomy category) is changed

‘set_object_terms’ is probably the hook you want. It gets passed the following: post_id, terms, term_taxonomy ids, taxonomy, append, old term_taxonomy ids. You can use the post_id and taxonomy params to determine if its the post type and taxonomy you want to hook into, and then check if term_taxonomy_ids differs from the old term_taxonomy_ids to decide … Read more

Divs appearing everywhere in post content

You first should find out where the divs are coming from, since that’s not normal behavior. Could be from a plugin or – as Damien said – copy-pasting a text from Word. To remove the divs you can do a simple str_replace(array(‘<div>’, ‘</div>’), ”, $content) either before storing the text in the database (by hooking … Read more

Auto-Tweet if Type is ‘Status’ using OAuth

My guess is that you aren’t hitting the {$old_status}_to_{$new_status} action, which is what you are hooking to with draft_to_published – for new posts there is no guarantee that the “old” status is actually “draft”. Have you tried using the {$new_status}_{$post->post_type} action, which in your case would be publish_status?

How to get the group_id from the “groups_join_group” action in buddypress [closed]

$group_id is the first argument passed to groups_join_group action hook function, the second argument is $user_id. You can use these data to obtain group creator_id like: add_action(‘groups_join_group’, ‘my_groups_join_group_action’, 10, 2); function my_groups_join_group_action($group_id, $user_id) { // use $group_id and $user_id here: $group = groups_get_group( array( ‘group_id’ => $group_id ) ); $creator_id = $group->creator_id; }

Display Something in the Header After All Styles are Loaded

Hook to wp_enqueue_scripts with a high priority number. For example: function load_my_style_wpse_90225() { wp_register_style( ‘mystyle’, get_template_directory_uri() .’/path/to/stylesheet.css’); wp_enqueue_style( ‘mystyle’ ); } add_action(‘wp_enqueue_scripts’,’load_my_style_wpse_90225′,1000); That should reasonably load last in line. Basically the same answer as here: Wooslider custom css Refernce http://codex.wordpress.org/Function_Reference/add_action

How to do a task only once for logged in users

There are various ways to do this, but I’ve recently addressed a similar problem by using cookies. add_action( ‘init’, ‘wpse_93797_cookie’ ); function wpse_93797_cookie() { if ( !isset ( $_COOKIE[‘wpse_93797_cookie_name’] ) ) { // Do your stuff. // Set your cookie so we don’t do stuff the next time around. // Note that 0 makes the … Read more