“Internal Server Error” with wp_update_post

Actually, there are 2 issues in your code: You were using PHP custom file name instead of menu_slug. You were not using action and method attributes of form tag. When you were submitting form WordPress redirecting into admin.php?on=Turn+Registration+On which is not a valid page. add_submenu_page function 4th parameter must be unique menu slug of your … Read more

How Can I Set the Post Author of a Post I Just Created With PHP?

If you know the ID of the author you can use wp_insert_post specifying the ID and the author ID to it. $id = $post->ID; // change this to whathever $user_id = ‘4’; // change this too $the_post = array(); $the_post[‘ID’] = $id; $the_post[‘post_author’] = $user_id; wp_insert_post( $the_post ); The trick is to specify the ID … Read more

Adding action to save_post, post needs to be saved twice for function to work

This is a stab in the dark, but have you tried using the set_object_terms hook for your bam_save_event_cat function? function bam_save_event_cat( $post_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { $taxonomy = ‘categoria’; $tribe_cats = get_the_terms( $post_id, ‘tribe_events_cat’); foreach($tribe_cats as $tribe_cat) { if( empty($tribe_cat->name) ) continue; $catname = $tribe_cat->name; $cats[] = $catname; } wp_set_object_terms( $post_id, $cats, … Read more

How to disable saving/changing update date for certain admin users?

A bare-bones version would look something like: function deny_post_date_change_wpse_131049( $data, $postarr ) { $user = wp_get_current_user(); // var_dump($user); die; // debugging if (in_array($user->ID,array(14,19))) { unset( $data[‘post_date’] ); unset( $data[‘post_date_gmt’] ); } return $data; } add_filter( ‘wp_insert_post_data’, ‘deny_post_date_change_wpse_131049’, 0, 2 ); I expect that in practice you probably want more complicated logic but that should get … Read more

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