Created
October 4, 2023 06:56
-
-
Save raftaar1191/12f4a3c5da81604470b9a042e362342b to your computer and use it in GitHub Desktop.
Do not allow activity to get posted without any Media
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add content into the post | |
*/ | |
function acrosswp_nouveau_ajax_post_update_custom() { | |
if ( ! is_user_logged_in() || empty( $_POST['_wpnonce_post_update'] ) || ! wp_verify_nonce( $_POST['_wpnonce_post_update'], 'post_update' ) ) { | |
wp_send_json_error(); | |
} | |
// check activity toolbar options if one of them is set, activity can be empty. | |
$toolbar_option = false; | |
if ( bp_is_active( 'media' ) && ! empty( $_POST['document'] ) ) { | |
$toolbar_option = true; | |
} elseif ( bp_is_active( 'media' ) && ! empty( $_POST['media'] ) ) { | |
$toolbar_option = true; | |
} elseif ( bp_is_activity_link_preview_active() && ! empty( $_POST['link_url'] ) ) { | |
$toolbar_option = true; | |
} elseif ( bp_is_active( 'media' ) && ! empty( $_POST['gif_data'] ) ) { | |
$toolbar_option = true; | |
} elseif ( bp_is_active( 'video' ) && ! empty( $_POST['video'] ) ) { | |
$toolbar_option = true; | |
} | |
if ( ! $toolbar_option ) { | |
wp_send_json_error( | |
array( | |
'message' => __( 'Please enter some media to post.', 'buddyboss' ), | |
) | |
); | |
} | |
} | |
add_action( 'wp_ajax_post_update', 'acrosswp_nouveau_ajax_post_update_custom', -1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment