[1]

tahir
Guest
August 7th, 2008 at 10:18 pm

Hi,

I am trying to create a form at http://www.customtoylab.com/show-us-your-toy/ so that it has a custom field for each seperate question asked at http://www.customtoylab.com/submit/ and automatically output the information like in the post http://www.customtoylab.com/2008/08/05/the-pantless-bunch-patrick-francisco/

I can not get the custom fields to display in the format of the post ocne submitted and the images do not show up only the links.

I also want the post to be [toy name] – [artist name] by automatically grabbing the information from the form.

Any idea how I should start

Thanks

Permalink | Quote

[2]

admin
Guest
August 8th, 2008 at 9:26 am

tahir said:
I am trying to create a form at http://www.customtoylab.com/show-us-your-toy/ so that it has a custom field for each seperate question asked at http://www.customtoylab.com/submit/ and automatically output the information like in the post http://www.customtoylab.com/2008/08/05/the-pantless-bunch-patrick-francisco/

I can not get the custom fields to display in the format of the post ocne submitted and the images do not show up only the links.

You should be able to enable, in the custom field widget, that the custom fields are appended to the post content and there is a field there to format them anyway you like.

As for image uploads, again there should be a number of options in the widget about how to display images. You have to have the file added as an attachment for a thumbnail, but it can be made to automatically generate the thumbnail and display it.

tahir said:
I also want the post to be [toy name] – [artist name] by automatically grabbing the information from the form.

That is slightly more complex, but doable. You will need the Append Widget, in this widget you’ll have to add code to grab the values of those custom fields for toy name and artist name. This topic goes through the details of how to do it to use the username however you’ll have to do something different.

Add an Append Widget to the form, make sure it’s the very last/bottom widget. Then you can use this code or a variant of it in the Append Widget:

<?php
/* assuming you have called the custom fields "toy name" and "artist name" respectivily... */

$toy_name = get_post_meta($post_id, 'toy name', true);
$artist_name = get_post_meta($post_id, 'artist name', true);

/* if you use the who am i widget you can take the artist name from the
 submitter values using %%USERNAME%% instead:
 i.e.: $artist_name = %%USERNAME%%; */

if($toy_name != false) {
   $post_title = '['.$toy_name.']';
} else {
   $post_title = '[no toy name set]';
}
$post_title .= ' - ';
if($artist_name != false) {
   $post_title .= '['.$artist_name.']';
} else {
   $post_title .= '[no artist name set]';
}

$postdata = array(
         "ID" => $post_id,
         "post_title" => $post_title;
      sanitize_post($postdata,"db");
      wp_update_post($postdata);
?>

I haven’t tested this code, but I’m fairly confident it’s correct.

Permalink | Quote

[3]

Alan VanNice
Guest
December 15th, 2008 at 5:47 pm

I am trying to use TDO miniforms to allow my visitors to post their personal information on my site. I have used the widgets panel to create a from with 5 custom fields.

I want the post title to be the value entered for Custom Field 1.

The Title of custom field 1 is Name, the Key Field Name is “name”.

I have added an append to post content 1 field at the end of my form and inserted the following code:

$post_id,
“post_title” => $post_title;
sanitize_post($postdata,”db”);
wp_update_post($postdata);
?>

Can anyone tell me what I am missing. I am new to php and I am struggling to make this work. It seems like this should be an easy thing to do, but it is not working for me.

Thanks in advance

Permalink | Quote

[4]

Mark Cunningham
Guest
December 17th, 2008 at 1:07 pm

Hi Alan, I’m assuming part of your code got lost there when you posted. Something like this should work for you:

<?php
/* assuming you have called the custom field key "name"... */

$post_title = get_post_meta($post_id, 'name', true);

$postdata = array(
"ID" => $post_id,
"post_title" => $post_title;
sanitize_post($postdata,"db");
wp_update_post($postdata);
?>

Permalink | Quote

[5]

Scott Hack
Guest
April 3rd, 2009 at 6:36 pm

Has anyone had luck doing this? I cut and pasted the code above that Mark Cunningham has provided. I put this this in an append to post box. The append to post box is the very last box on the form. Directly above that I created a custom field and I tied the custom field to the name field key. I can’t get it to work.

Permalink | Quote

[6]

Mark Cunningham
Guest
April 14th, 2009 at 9:16 am

Scott Hack said:
Has anyone had luck doing this? I cut and pasted the code above that Mark Cunningham has provided. I put this this in an append to post box. The append to post box is the very last box on the form. Directly above that I created a custom field and I tied the custom field to the name field key. I can’t get it to work.

There is a little code syntax bug in it, missing a closing bracket:

<?php
/* assuming you have called the custom field key "name"... */

$post_title = get_post_meta($post_id, 'name', true);

$postdata = array( "ID" => $post_id, "post_title" => $post_title);
sanitize_post($postdata,"db");
wp_update_post($postdata);
?>

Permalink | Quote

[7]

Yc
Guest
April 18th, 2009 at 7:59 pm

I finally got it working by using echo

ID, ‘Author Name’, true); ?>

That returns the author name, for me.

Permalink | Quote

[8]

Yc
Guest
April 18th, 2009 at 8:07 pm

Damn. Sorry, I didn’t remove formatting. It’s this:

Submitted by ID, ‘Author Name’, true); ?>

Permalink | Quote

[9]

Mark Cunningham
Guest
May 12th, 2009 at 10:52 am

Replace < with &lt; and > with &gt; when posting. Otherwise WordPress strips it out for security.

Permalink | Quote

[10]

Matt
Guest
April 10th, 2010 at 8:15 pm

Hello,

I am trying to take the post name and add a date on the end of it. I have a custom field called ‘startdate’. As it stands, only the date shows up in the title. So, I’m sure that I’m not doing something right with the original title. Here is what I have tried:

<?php
the_title($display, false);

$date_title = get_post_meta($post_id, ‘startdate’, true);

$full_title = $display . ” ” . $date_title;

$postdata = array( “ID” => $post_id, “post_title” => $full_title);
sanitize_post($postdata,”db”);
wp_update_post($postdata);
?>

I appreciate any help!

Permalink | Quote

[11]

dr.crash
Guest
June 29th, 2010 at 10:27 pm

When I use this technique, it works fine and my posts have the proper text. But in my admin dashpoard under Edit Posts, all the posts made with this approach are missing a post title. It just says “(no title)”

Is this correct???

Thanks!

Mark Cunningham said:

Scott Hack said:
Has anyone had luck doing this? I cut and pasted the code above that Mark Cunningham has provided. I put this this in an append to post box. The append to post box is the very last box on the form. Directly above that I created a custom field and I tied the custom field to the name field key. I can’t get it to work.

There is a little code syntax bug in it, missing a closing bracket:

<?php
/* assuming you have called the custom field key "name"... */

$post_title = get_post_meta($post_id, 'name', true);

$postdata = array( "ID" => $post_id, "post_title" => $post_title);
sanitize_post($postdata,"db");
wp_update_post($postdata);
?>

Permalink | Quote

Advertisments

Join the Discussion