Is there a way to set a user profile to Draft?

The database table for users holds the user_status as integer: $users_single_table = “CREATE TABLE $wpdb->users ( ID bigint(20) unsigned NOT NULL auto_increment, user_login varchar(60) NOT NULL default ”, user_pass varchar(255) NOT NULL default ”, user_nicename varchar(50) NOT NULL default ”, user_email varchar(100) NOT NULL default ”, user_url varchar(100) NOT NULL default ”, user_registered datetime NOT … Read more

wp_delete_auto_drafts() deletes links in menus

This is what normal query run by wp_get_associated_nav_menu_items() looks like: SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id ) WHERE 1 = 1 AND wp_posts.post_type=”nav_menu_item” AND (( wp_posts.post_status <> ‘trash’ AND wp_posts.post_status <> ‘auto-draft’ )) AND (( wp_postmeta.meta_key = ‘_menu_item_object_id’ AND Cast(wp_postmeta.meta_value AS CHAR) = ‘3111’ )) GROUP BY wp_posts.id ORDER … Read more

How to get the clean permalink in a draft?

This is a little “hacky”, but when you call get_permalink and you need the permalink for a draft, provide a clone of your post object with the details filled in: global $post; if ( in_array( $post->post_status, array( ‘draft’, ‘pending’, ‘auto-draft’ ) ) ) { $my_post = clone $post; $my_post->post_status=”publish”; $my_post->post_name = sanitize_title( $my_post->post_name ? $my_post->post_name … Read more

Passing current cookies in wp_remote_get to get Draft Post Preview

I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user’s cookies to retrieve preview page source: $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( ‘preview_post_link’, add_query_arg( ‘preview’, ‘true’, $preview_link ) ) ); $cookies = array(); foreach ( $_COOKIE as $name … Read more