Skip to content

Instantly share code, notes, and snippets.

@dcavins
Created April 13, 2021 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcavins/65154f3f39c1a8cf8e78dadd2992a6a7 to your computer and use it in GitHub Desktop.
Save dcavins/65154f3f39c1a8cf8e78dadd2992a6a7 to your computer and use it in GitHub Desktop.
Set every new BP doc to pending status.
<?php
/**
* Mark all new docs as pending.
*
* @param array $r The parameters to be used in wp_insert_post().
* @param object $this The BP_Docs_Query object.
* @param array $args The passed and filtered parameters for the doc
* about to be saved.
*/
function bpdocs_support_mark_all_as_pending( $save_args, $bdq_object, $passed_args ) {
if ( ! current_user_can( 'bp_moderate' ) && $bdq_object->is_new_doc ) {
// Set the post status as "pending".
$save_args['post_status'] = 'bp_docs_pending';
}
return $save_args;
}
add_filter( 'bp_docs_post_args_before_save', 'bpdocs_support_mark_all_as_pending', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment