How to switch wordpress post status between publish and schedule in MySQL?
How to switch wordpress post status between publish and schedule in MySQL?
How to switch wordpress post status between publish and schedule in MySQL?
Decide user that can publish a post
I have the below code which works as expected if anyone else is looking for similar. add_action( ‘publish_page’, ‘redirect_user_page_list’, 10, 3 ); function redirect_user_page_list() { if( is_user_logged_in() ) { $user = wp_get_current_user(); $role = ( array ) $user->roles; if ( ‘role_slug’ == $role[0] ) { $url=”url to redirect to”; wp_redirect($url); exit; } } }
Publish Post when URL is available else reschedule the post in wordpress [duplicate]
Try this: add_action(‘publish_post’, ‘dp_expiry’); function dp_expiry( $data ) { /*adds 2 weeks onto the current date in unix epoch format*/ $dp_new_expiry_date = (strtotime( current_time( ‘mysql’ ) ) + 1209600); /*converts unix timstamp back to yyyy-mm-dd format like you required*/ $dp_new_expiry_date_conv = date(“Y-m-d”, $dp_new_expiry_date); update_post_meta( $data[‘post_id’], ‘postexpiry’, $dp_new_expiry_date_conv ); }
The $post you’re working with is a WP_Post Object and you must interact with it as so. $post->post_status=”draft”; It’s usually not a good practice to modify the $post object directly so it’s something you may want to avoid. A better way may be to simply pass an array of values to wp_update_post() function like so: … Read more
I got it working by looking at this post/answer: https://wordpress.stackexchange.com/a/134283/17126 Seems it can’t be done, and I changed the get_post_meta line to: $message .= ‘Email: ‘ . sanitize_text_field($_POST[‘_email’]) . ‘<br>’; Also, I could see the $_POST data coming in from post.php on submission over dev tools. And finally, I changed my hook to publish_cpt which … Read more
Found Solution : If there is no data in the request_body, the we can also fetch it from the postID which is already we have. Changed Code: added condition if data not available, then get it from post id public static function saveDataInNotificationTable($ID,$request_body) { $post_data = json_decode($request_body); $tags = $post_data->tags; if($post_data == “” || $post_data … Read more
Working code: add_action( ‘acf/save_post’, ‘fritlaeg_artikel_3m’ ); function fritlaeg_artikel_3m( $post_id ) { if( get_post_meta( $post_id, ‘fritlaeg_artikel_i_3_maneder’, true ) ) { // Getting a UNIX Timestamp $timestamp = time(); // Using WordPress Time Constants // https://codex.wordpress.org/Easier_Expression_of_Time_Constants $timestamp_after_hour = $timestamp + 0.5 * MINUTE_IN_SECONDS; // Define remaining parameters $args = array( $post_id ); $hook = ‘fritlaegning_clear_meta_data’; // Get … Read more
Changing wordpress publication date to ACF date and time picker date not working