How to assign default taxonomy to pages on ‘save_post’?

You are using wp_set_object_terms wrong, the second parameter should be the term slug or id and the 3 parameter should be the taxonomy name, so try: function set_default_object_terms( $id, $post ) { if ( ‘publish’ === $post->post_status ) { log_me (‘be in function while “publish” i pressed with this id: ‘.$id); $taxonomy_ar = get_terms( ‘property-features’ … Read more

Action ‘save_post’ not working for quick edit

It’s just a guess, since I haven’t tested your code, but… There is a part that looks pretty sketchy for me: All your actions are run only if this condition is true: if(isset($post_type) && $post_type == “listings”){ And where that $post_type variable comes from? $post_type = get_post_type(); So you don’t pass any post_id to that … Read more

How to stop a user from updating the post date

As @t-f pointed out in his comment to question, you have an error on checking current user capability: ‘delete_published_posts’. $post_author_id simply doesn’t exist. After that, for your scope probably is a better hookin the filter wp_insert_post_data instead of the action save_post: because this one run when the post was already saved / updated, so if … Read more

Disallow a user to post in certain categories

save_post is too late. Look at the source and you can see that the post has already been saved when that hook fires. You will have to interrupt the process well before that hook if you want to prevent saving. I think I would lean toward something like this: add_filter( ‘post_updated_messages’, function($messages) { $messages[‘post’][11] = … Read more

Check if value has changed on save_post

In the end I checked against and updated a new meta value on each save. $screen = get_current_screen(); if ( $screen->base == ‘post’ && $screen->post_type == ‘sessions’) { if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; if ( isset( $_POST[‘session_status_tax’] ) ) { $status = $_POST[‘session_status_tax’]; } else { $status=””; } $prev_term = get_post_meta( … Read more

Why is my custom meta box input not saving

Try changing: <input class=”widefat” type=”text” placeholder=”[galleryview id=X]” name=”rs-job-gallery” id=”rs-job-gallery” value=”<?php echo esc_attr( get_post_meta( $object->ID, ‘rs_job_gallery’, true ) ); ?>” size=”30″/> to this: <input class=”widefat” type=”text” placeholder=”[galleryview id=X]” name=”rs_job_gallery” id=”rs-job-gallery” value=”<?php echo esc_attr( get_post_meta( $object->ID, ‘rs_job_gallery’, true ) ); ?>” size=”30″/> Reason: When the “name” attribute is set in the input field, that becomes the $_POST[‘input_name’] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)