Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ultimate Member Groups - Create discussion post
function wpuf_post_umgroup( $post_id, $form_id ) {
/* Build the post content by adding the referer URL to the comment and update the post */
$lv_comment = $_POST['_my_comment'] . PHP_EOL . PHP_EOL . home_url() . wp_get_referer();
$lv_post = array();
$lv_post['ID'] = $post_id;
$lv_post['post_author'] = get_current_user_id();
$lv_post['post_content'] = $lv_comment;
$lv_post['post_type'] = "um_groups_discussion";
wp_update_post( $lv_post );
/* Update the post meta fields needed for UM Groups see hidden fields in WPUF form */
update_post_meta( $post_id, '_original_content', $lv_comment );
update_post_meta( $post_id, '_user_id', get_current_user_id() );
update_post_meta( $post_id, '_wall_id', '1');
update_post_meta( $post_id, '_action', 'status');
update_post_meta( $post_id, '_user_id', get_current_user_id());
update_post_meta( $post_id, '_group_id', 28330);
update_post_meta( $post_id, '_group_moderation', 'approved');
add_action( 'wpuf_add_post_after_insert', 'wpuf_post_umgroup' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment