How to attach user input to image using php, inside WordPress?
We recently took an ongoing project offering web maintenance.
We have to provide the users with a questionnaire, at the end of which they - the users, will receive a diploma. We need a way of attaching the user's name, entered inside an input tag to an image, the diploma template if you would allow.
Forgetting about the WordPress part, this looks nice and smooth, alongside the PHP manual. But in order for us to do that, we need to find a way of displaying that image inside a post.
The following lines are responsible for manipulating the image, attach the string and build the post for the image to live in.
add_action( 'init', 'custom_post_type', 0 );
add_action( 'wp_ajax_diploma_new_image', 'diploma_new_image' );
add_action( 'wp_ajax_nopriv_diploma_new_image', 'diploma_new_image' );
function diploma_new_image()
$upload_dir = wp_upload_dir();
$rImg = ImageCreateFromJPEG($_POST['data']['image_path']);
$cor = imagecolorallocate($rImg, 255, 255, 255);
imagestring($rImg,50,150,550,urldecode(strtoupper($_POST['data']'filename'])),$cor);
header('Content-type: image/jpeg');
imagejpeg($rImg, $upload_dir['basedir']."/diploma_new/".str_replace(' ', '_', $_POST['data']['filename']),100);
$title = $_POST['data']['names'].'_diploma'.rand(1,90);
$description ='[fusion_builder_container ][fusion_builder_row][fusion_builder_column][fusion_title]Diplomă în anticorupție[/fusion_title][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
<div><h4>Descarca diploma ta in anticoruptie.</h4></div>
<div><img src="'.$upload_dir['baseurl'].'/diploma_new/'.str_replace(' ', '_', $_POST['data'].round(['filename'])).'" /></div>';
$cat='cat';
$tags='tags';
$post = array(
'post_title' => $title,
'post_content' => $description,
'post_category' => $cat,
'tags_input' => $tags,
'post_status' => 'publish',
'post_type' => 'post',
'tax_input' => array( 'category' => '98' )
);
wp_insert_post($post);
;
add_action( 'wp_ajax_get_details_diploma', 'get_details_diploma' );
add_action( 'wp_ajax_nopriv_get_details_diploma', 'get_details_diploma' );
function get_details_diploma()
$sucess_message = "detail functions";
global $wpdb;
$query = $wpdb->get_results("SELECT * FROM `wp_posts` ORDER BY id DESC limit 1 ");
$url = get_permalink($query[0]->ID);
echo $url;
die();
;
The trigger for the image comes from within jQuery
echo '<div class="name_form">
<input type="text" name="field1" id="diploma_name" value=" " placeholder=" name "required="required">
<button name="submit" id="diploma_submit" value="submit"> Scrie-ți numele pentru a personaliza diploma!</button>
</div>
<div style="margin-top: 50px;" id="diploma_name_display">
</div>
<script>
jQuery(document).ready(function()
jQuery("#diploma_submit").click(function()
var firstfield_value = jQuery("#diploma_name").val();
jQuery("#diploma_name_display").html( "<strong>" + firstfield_value +"</strong>" );
c = navigator.userAgent.search("Firefox");
if (c > -1)
jQuery("#diploma_name_display").css("margin-top: 50px;");
// $.window.stop(); //don't mind this, I have added this to stop the page from refreshing so my boss thinks this actually work.
);
);
</script>';
I am not yet sure where it breaks, if I look in the source panel of dev tools, I can see the 404 on the image, meaning it was not generated, or saved, or both. Do you have any idea of solving this challenge?
source view for the diploma file
php wordpress
add a comment |
We recently took an ongoing project offering web maintenance.
We have to provide the users with a questionnaire, at the end of which they - the users, will receive a diploma. We need a way of attaching the user's name, entered inside an input tag to an image, the diploma template if you would allow.
Forgetting about the WordPress part, this looks nice and smooth, alongside the PHP manual. But in order for us to do that, we need to find a way of displaying that image inside a post.
The following lines are responsible for manipulating the image, attach the string and build the post for the image to live in.
add_action( 'init', 'custom_post_type', 0 );
add_action( 'wp_ajax_diploma_new_image', 'diploma_new_image' );
add_action( 'wp_ajax_nopriv_diploma_new_image', 'diploma_new_image' );
function diploma_new_image()
$upload_dir = wp_upload_dir();
$rImg = ImageCreateFromJPEG($_POST['data']['image_path']);
$cor = imagecolorallocate($rImg, 255, 255, 255);
imagestring($rImg,50,150,550,urldecode(strtoupper($_POST['data']'filename'])),$cor);
header('Content-type: image/jpeg');
imagejpeg($rImg, $upload_dir['basedir']."/diploma_new/".str_replace(' ', '_', $_POST['data']['filename']),100);
$title = $_POST['data']['names'].'_diploma'.rand(1,90);
$description ='[fusion_builder_container ][fusion_builder_row][fusion_builder_column][fusion_title]Diplomă în anticorupție[/fusion_title][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
<div><h4>Descarca diploma ta in anticoruptie.</h4></div>
<div><img src="'.$upload_dir['baseurl'].'/diploma_new/'.str_replace(' ', '_', $_POST['data'].round(['filename'])).'" /></div>';
$cat='cat';
$tags='tags';
$post = array(
'post_title' => $title,
'post_content' => $description,
'post_category' => $cat,
'tags_input' => $tags,
'post_status' => 'publish',
'post_type' => 'post',
'tax_input' => array( 'category' => '98' )
);
wp_insert_post($post);
;
add_action( 'wp_ajax_get_details_diploma', 'get_details_diploma' );
add_action( 'wp_ajax_nopriv_get_details_diploma', 'get_details_diploma' );
function get_details_diploma()
$sucess_message = "detail functions";
global $wpdb;
$query = $wpdb->get_results("SELECT * FROM `wp_posts` ORDER BY id DESC limit 1 ");
$url = get_permalink($query[0]->ID);
echo $url;
die();
;
The trigger for the image comes from within jQuery
echo '<div class="name_form">
<input type="text" name="field1" id="diploma_name" value=" " placeholder=" name "required="required">
<button name="submit" id="diploma_submit" value="submit"> Scrie-ți numele pentru a personaliza diploma!</button>
</div>
<div style="margin-top: 50px;" id="diploma_name_display">
</div>
<script>
jQuery(document).ready(function()
jQuery("#diploma_submit").click(function()
var firstfield_value = jQuery("#diploma_name").val();
jQuery("#diploma_name_display").html( "<strong>" + firstfield_value +"</strong>" );
c = navigator.userAgent.search("Firefox");
if (c > -1)
jQuery("#diploma_name_display").css("margin-top: 50px;");
// $.window.stop(); //don't mind this, I have added this to stop the page from refreshing so my boss thinks this actually work.
);
);
</script>';
I am not yet sure where it breaks, if I look in the source panel of dev tools, I can see the 404 on the image, meaning it was not generated, or saved, or both. Do you have any idea of solving this challenge?
source view for the diploma file
php wordpress
add a comment |
We recently took an ongoing project offering web maintenance.
We have to provide the users with a questionnaire, at the end of which they - the users, will receive a diploma. We need a way of attaching the user's name, entered inside an input tag to an image, the diploma template if you would allow.
Forgetting about the WordPress part, this looks nice and smooth, alongside the PHP manual. But in order for us to do that, we need to find a way of displaying that image inside a post.
The following lines are responsible for manipulating the image, attach the string and build the post for the image to live in.
add_action( 'init', 'custom_post_type', 0 );
add_action( 'wp_ajax_diploma_new_image', 'diploma_new_image' );
add_action( 'wp_ajax_nopriv_diploma_new_image', 'diploma_new_image' );
function diploma_new_image()
$upload_dir = wp_upload_dir();
$rImg = ImageCreateFromJPEG($_POST['data']['image_path']);
$cor = imagecolorallocate($rImg, 255, 255, 255);
imagestring($rImg,50,150,550,urldecode(strtoupper($_POST['data']'filename'])),$cor);
header('Content-type: image/jpeg');
imagejpeg($rImg, $upload_dir['basedir']."/diploma_new/".str_replace(' ', '_', $_POST['data']['filename']),100);
$title = $_POST['data']['names'].'_diploma'.rand(1,90);
$description ='[fusion_builder_container ][fusion_builder_row][fusion_builder_column][fusion_title]Diplomă în anticorupție[/fusion_title][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
<div><h4>Descarca diploma ta in anticoruptie.</h4></div>
<div><img src="'.$upload_dir['baseurl'].'/diploma_new/'.str_replace(' ', '_', $_POST['data'].round(['filename'])).'" /></div>';
$cat='cat';
$tags='tags';
$post = array(
'post_title' => $title,
'post_content' => $description,
'post_category' => $cat,
'tags_input' => $tags,
'post_status' => 'publish',
'post_type' => 'post',
'tax_input' => array( 'category' => '98' )
);
wp_insert_post($post);
;
add_action( 'wp_ajax_get_details_diploma', 'get_details_diploma' );
add_action( 'wp_ajax_nopriv_get_details_diploma', 'get_details_diploma' );
function get_details_diploma()
$sucess_message = "detail functions";
global $wpdb;
$query = $wpdb->get_results("SELECT * FROM `wp_posts` ORDER BY id DESC limit 1 ");
$url = get_permalink($query[0]->ID);
echo $url;
die();
;
The trigger for the image comes from within jQuery
echo '<div class="name_form">
<input type="text" name="field1" id="diploma_name" value=" " placeholder=" name "required="required">
<button name="submit" id="diploma_submit" value="submit"> Scrie-ți numele pentru a personaliza diploma!</button>
</div>
<div style="margin-top: 50px;" id="diploma_name_display">
</div>
<script>
jQuery(document).ready(function()
jQuery("#diploma_submit").click(function()
var firstfield_value = jQuery("#diploma_name").val();
jQuery("#diploma_name_display").html( "<strong>" + firstfield_value +"</strong>" );
c = navigator.userAgent.search("Firefox");
if (c > -1)
jQuery("#diploma_name_display").css("margin-top: 50px;");
// $.window.stop(); //don't mind this, I have added this to stop the page from refreshing so my boss thinks this actually work.
);
);
</script>';
I am not yet sure where it breaks, if I look in the source panel of dev tools, I can see the 404 on the image, meaning it was not generated, or saved, or both. Do you have any idea of solving this challenge?
source view for the diploma file
php wordpress
We recently took an ongoing project offering web maintenance.
We have to provide the users with a questionnaire, at the end of which they - the users, will receive a diploma. We need a way of attaching the user's name, entered inside an input tag to an image, the diploma template if you would allow.
Forgetting about the WordPress part, this looks nice and smooth, alongside the PHP manual. But in order for us to do that, we need to find a way of displaying that image inside a post.
The following lines are responsible for manipulating the image, attach the string and build the post for the image to live in.
add_action( 'init', 'custom_post_type', 0 );
add_action( 'wp_ajax_diploma_new_image', 'diploma_new_image' );
add_action( 'wp_ajax_nopriv_diploma_new_image', 'diploma_new_image' );
function diploma_new_image()
$upload_dir = wp_upload_dir();
$rImg = ImageCreateFromJPEG($_POST['data']['image_path']);
$cor = imagecolorallocate($rImg, 255, 255, 255);
imagestring($rImg,50,150,550,urldecode(strtoupper($_POST['data']'filename'])),$cor);
header('Content-type: image/jpeg');
imagejpeg($rImg, $upload_dir['basedir']."/diploma_new/".str_replace(' ', '_', $_POST['data']['filename']),100);
$title = $_POST['data']['names'].'_diploma'.rand(1,90);
$description ='[fusion_builder_container ][fusion_builder_row][fusion_builder_column][fusion_title]Diplomă în anticorupție[/fusion_title][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
<div><h4>Descarca diploma ta in anticoruptie.</h4></div>
<div><img src="'.$upload_dir['baseurl'].'/diploma_new/'.str_replace(' ', '_', $_POST['data'].round(['filename'])).'" /></div>';
$cat='cat';
$tags='tags';
$post = array(
'post_title' => $title,
'post_content' => $description,
'post_category' => $cat,
'tags_input' => $tags,
'post_status' => 'publish',
'post_type' => 'post',
'tax_input' => array( 'category' => '98' )
);
wp_insert_post($post);
;
add_action( 'wp_ajax_get_details_diploma', 'get_details_diploma' );
add_action( 'wp_ajax_nopriv_get_details_diploma', 'get_details_diploma' );
function get_details_diploma()
$sucess_message = "detail functions";
global $wpdb;
$query = $wpdb->get_results("SELECT * FROM `wp_posts` ORDER BY id DESC limit 1 ");
$url = get_permalink($query[0]->ID);
echo $url;
die();
;
The trigger for the image comes from within jQuery
echo '<div class="name_form">
<input type="text" name="field1" id="diploma_name" value=" " placeholder=" name "required="required">
<button name="submit" id="diploma_submit" value="submit"> Scrie-ți numele pentru a personaliza diploma!</button>
</div>
<div style="margin-top: 50px;" id="diploma_name_display">
</div>
<script>
jQuery(document).ready(function()
jQuery("#diploma_submit").click(function()
var firstfield_value = jQuery("#diploma_name").val();
jQuery("#diploma_name_display").html( "<strong>" + firstfield_value +"</strong>" );
c = navigator.userAgent.search("Firefox");
if (c > -1)
jQuery("#diploma_name_display").css("margin-top: 50px;");
// $.window.stop(); //don't mind this, I have added this to stop the page from refreshing so my boss thinks this actually work.
);
);
</script>';
I am not yet sure where it breaks, if I look in the source panel of dev tools, I can see the 404 on the image, meaning it was not generated, or saved, or both. Do you have any idea of solving this challenge?
source view for the diploma file
php wordpress
php wordpress
asked Nov 12 '18 at 13:57
Alin AndreiAlin Andrei
36
36
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263704%2fhow-to-attach-user-input-to-image-using-php-inside-wordpress%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263704%2fhow-to-attach-user-input-to-image-using-php-inside-wordpress%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown