Disable revision access for a specific user role

I resolved this in the end by removing access to the revisions meta box for certain user types… if (get_current_user_role()==”custom_user_role”){ function my_remove_revisions() { remove_meta_box(‘revisionsdiv’, ‘apartments’, ‘normal’); } add_action( ‘admin_menu’, ‘my_remove_revisions’ ); }

Get last revision author, author-link and date

To get the_modified_author() we have to look in the folder wp-includes and search for the author-template.php. Line 101 shows: /** * Display the name of the author who last edited the current post, * if the author’s ID is available. * * @since 2.8.0 * * @see get_the_author() */ function the_modified_author() { echo get_the_modified_author(); } … Read more

Post revisions disappeared (for some posts)

Check your database to see if the revisions are still there. Use phpmyadmin or another database tool and go to wp_posts table and search for post_type = revision. If they are not there, they are gone. A lot of “optimization” plugins remove post revisions for you. I would check if any of your plugins has … Read more

Define a wordpress constant through plugin functions?

I don’t think you should define constants in your plugin. It will be very hard to debug later on. IMHO using wp_revisions_to_keep filter will be much nicer solution. So your code could look like this: add_filter( ‘wp_revisions_to_keep’, ‘my_revisions_to_keep_based_on_settings’, 10, 2 ); function my_revisions_to_keep_based_on_settings( $num, $post ) { // change that according to your needs return … Read more

Show history of post revisions on front end

Your shortcode calls wp_list_post_revisions() which echo the output (revision list), hence you get the “updating error”. To fix the issue, you can use output buffering like so: ob_start(); wp_list_post_revisions( get_the_ID() ); $revisions = ob_get_clean(); Or you could use wp_get_post_revisions() and build the HTML list manually. Here’s an example based on the wp_list_post_revisions(): $output=””; if ( … Read more