Connect with us

Consumer Forum




is_valid;
} else {
$continue = true;
}
if( $continue ) {
$showForm = false;
$postId = wp_insert_post( array( ‘post_title’ => $_POST [ ‘news-title’ ], ‘post_author’ => 16, ‘post_content’ => $_POST [ ‘news-description’ ], ‘post_status’ => ‘publish’, ‘post_type’ => ‘consumerforum’ ), $wp_error );
$name = $facebookUserId ? $facebookUserInfo[ ‘name’ ] : $_POST[ ‘your-name’ ];
$name = $facebookUserId ? $facebookUserInfo[ ’email’ ] : $_POST[ ‘your-email’ ];
update_post_meta($postId, ‘userName’, $name );
update_post_meta($postId, ‘userEmail’, $email );
wp_set_object_terms( $postId, array( 3699 ), ‘category’ );
require_once(ABSPATH . ‘wp-admin/includes/file.php’);

foreach( $_FILES[ ‘your-image’ ][‘name’] as $i => $fileName ) {
$file = array(
‘name’ => $_FILES[ ‘your-image’ ][‘name’][$i],
‘type’ => $_FILES[ ‘your-image’ ][‘type’][$i],
‘tmp_name’ => $_FILES[ ‘your-image’ ][‘tmp_name’][$i],
‘error’ => $_FILES[ ‘your-image’ ][‘error’][$i],
‘size’ => $_FILES[ ‘your-image’ ][‘size’][$i],
);

$file = wp_handle_upload( $file, array( ‘test_form’ => FALSE ) );
$filename = $file[ ‘file’ ];
$wp_filetype = wp_check_filetype(basename($filename), null );
$wp_upload_dir = wp_upload_dir();
$attachment = array(
‘guid’ => $wp_upload_dir[‘url’] . ‘/’ . basename( $filename ),
‘post_mime_type’ => $wp_filetype[‘type’],
‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename($filename)),
‘post_content’ => ”,
‘post_status’ => ‘inherit’
);
$attach_id = wp_insert_attachment( $attachment, $filename, $postId );
require_once(ABSPATH . ‘wp-admin/includes/image.php’);
$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
wp_update_attachment_metadata( $attach_id, $attach_data );
if( $i == 0 )
set_post_thumbnail( $postId, $attach_id );
}
wp_mail( array( ‘admin@himachalwatcher.com’ ), ‘New Urnewz – ‘ . $_POST [ ‘news-title’ ], $_POST [ ‘your-name’ ] );
echo ‘

Thank your for your news submission. You\’ll be redirected to your news shortly.

‘;
echo ‘‘;
} else {
echo ‘

You\’ve submitted invalid captcha text.

‘;
}
}
if( $showForm && $facebookUserId ) {
?>

Login via facebook …

or enter your details …

Your Name (required)

Your Email (required)

News Title (required)

Description (required)

Image(s) – required [ You can select multiple files and maximum of 5. ]