Skip to content


Subversion checkout URL

You can clone with
Download ZIP


document_to_private Filter brings Notice...? #39

deckerweb opened this Issue · 5 comments

2 participants


Using the "document_to_private" filter to re-set to "publish":

add_filter( 'document_to_private', 'ddw_wpdrsd_default_visibility_public', 10, 2 );
function ddw_wpdrsd_default_visibility_public( $post, $post_pre ) {

    global $post;

    if ( 'document' == get_post_type( $post ) ) {
        return $post_pre;


Is working!
BUT bringing this notice:

NOTICE: wp-content/plugins/wp-document-revisions/wp-document-revisions.php:372 - Trying to get property of non-object

Don't know what to do about this, hope you can help to get the notice fixed.

Thanks, Dave :)


My guess is that at somepoint the post_type is not document, and because you're not returning the original post, it errors out. I'd just return $post_pre in all cases (this filter only fires for documents), or remove the global $post call, and return $post on the last line.


Both suggestions work, but the notice doesn't get away...


Not sure what's going on there. The other guess (which I believe I've done before without error), return $post (rather than $post_pre, but before you do, set the post status to $post_pre's. e.g.,

$post->post_status = $post_pre->post_status;
return $post;

Hi Ben!
Tried all suggestions - while they all do work, the notice doesn't go away... Tried a lot more things. IMHO it may be somethings with "attachments" or so?

However, the background of this question was my little add-on plugin I just released! There the above code is used for a little setting of the add-on --- but this setting (setting visibility to "publish") is disabled by default, of course. Unfortunately, I had to release with unresolved notice but I wouldn't wait any more weeks. Maybe you and the community could help me better to figure this out. If this issue can't be resolved, no prob, so I may remove this little setting and users can always choose visibility manually.

So, here's the little plugin if you're interested in playing around, hope you'll like it:
---> Just works via Hooks & Filters, does not make any permanent modifications. Just for "re-branding" as "Downloads" and adding a few more widgets.

Thanks, Dave :)


Closing as stale, please feel free to reopen if this is still occurring.

@benbalter benbalter closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.