Change post status based on user role

I’m then trying to figure out how to change the post status once their subscription is up function downgrade_user_role( $entry, $subscription_id, $transaction_id, $new_payment_amount ) { $user = GFUserData::get_user_by_entry_id( $entry[‘id’] ); $user->set_role( ‘subscriber’ ); global $wpdb; $wpdb->query( $wpdb->prepare( “UPDATE $wpdb->posts SET post_status=”draft” WHERE post_author = %d AND post_status IN (‘publish’, ‘future’)”, $user->ID ) ); } add_action( … Read more

Change name of existing post status type

A number of admin interfaces are hardcoded to return the default statuses regardless of what you do. The post status system in WordPress is not exactly fully formed and you’ll no doubt encounter bugs. Refer to the edit flow plugin for examples of working around this

Function to change post status IF current user and post author are the same

I was unable to find any action called wp_update_post. Are you sure it’s a valid one? Lets try the hook publish_post. add_action(‘publish_post’, ‘check_user_publish’, 10, 2); function check_user_publish ($post_id, $post) { $user_id = get_current_user_id(); if ($user_id != $post->post_author) return; $query = array( ‘ID’ => $post_id, ‘post_status’ => ‘draft’, ); wp_update_post( $query, true ); }} code not … Read more

Wp_query Add specific pending posts

Your setup isn’t supported by WP_Query. One approach is to use the posts_where filter of WP_Query (there are other ways possible, like collecting post ID’s instead from different queries.) to adjust the SQL query. To avoid string replaces we could use for example: $custom_query_args = [ ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ]; // Add … Read more

how to remove dash (-) post status from post title on posts listing page wordpress

Try the following: add_filter(‘display_post_states’, ‘__return_false’); The function responsible for printing the post state on the post list table is: _post_states() Located in wp-admin/includes/template.php. The following logic determines whether the state will be printed: /** * Filter the default post display states used in the posts list table. * * @since 2.8.0 * * @param array … Read more

Add a simple JS Alert Box on Post Submission

Note that when post is update WordPress redirect you from /wp-admin/post.php to /wp-admin/post.php?post=41&action=edit which mean it loads twice. Thus what you will do on transition status hooks that will be skipped before the content is printed. Solution:- In transition hook callback function store (post meta) some flag to display js popup Bind a new function … Read more

Is it possible to change an existing post status from ‘pending’ to ‘publish’ via email?

Step 1 – Register a Custom Query Var By adding a custom query var, you make WP aware of it so it can be used in requests. function wpse_add_query_vars( $vars ) { $vars[] = ‘wpse_set_to_publish’; return $vars; } add_filter( ‘query_vars’, ‘wpse_add_query_vars’ ); Step 2 – Sniff The Request Now we hook into parse_request to look … Read more

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