[1]

romain_becket
Subscriber
March 12th, 2009 at 11:11 pm

Good evening,
First of all, I would like to say to the author of this plugin : you are really a genius. Chapeau ! I tried to start a plugin, but really to difficult for me now.

Now I would like only to implement the possibility to reply at a post (to create a correspondence between to user). To do that, I post the ID of a post (name : ‘AutosID’) from a page to the ‘reply’ page (make with TDO form plugin).

In my ‘reply’ page, I use the “Append to Content” widget and add some code as you said Mark in a other topic.

Permalink | Quote

[2]

romain_becket
Subscriber
March 12th, 2009 at 11:16 pm

Good evening,
First of all, I would like to say to the author of this plugin : you are really a genius. Chapeau ! I tried to start a plugin, but really to difficult for me now.

Now I would like only to implement the possibility to reply at a post (to create a correspondence between to user). To do that, I post the ID of a post (name : ‘AutosID’) from a page to the ‘reply’ page (make with TDO form plugin).

In my ‘reply’ page, I use the “Append to Content” widget and add some code as you said Mark in a other topic.

<?php
if(isset($_POST['AutosID'])){
$autosID=$_POST['AutosID'];
$destis=strtolower(trim(get_the_author($autosID)));
add_meta_value($post_ID,’Destis’,$destis);
}

to retrieve and store the name of the author of the first post.
But it doesn’t work. The meta-value isn’t created.
Could you help me ?

Best regards,
Romain

Permalink | Quote

[3]

romain_becket
Subscriber
March 12th, 2009 at 11:33 pm

Little modification of the code :

post_author;
add_meta_value($post_ID,’Destis’,$destis);
}
?>
but it still doesn’t work.

Permalink | Quote

[4]

romain_becket
Subscriber
March 12th, 2009 at 11:36 pm

Little modification of the code :

post_author;
add_meta_value($post_ID,’Destis’,$destis);
}
?>

but it still doesn’t work.

Permalink | Quote

[5]

romain_becket
Subscriber
March 12th, 2009 at 11:42 pm

Sorry for this third same post but it s strange because a part of my post is always cut.
Little modification of the code :

if(isset($_POST['AutosID'])){
$autosID=$_POST['AutosID'];
$post_id_destis=get_post($autosID);
$destis = $post_id_destis->post_author;
add_meta_value($post_ID,’Destis’,$destis);
}

Permalink | Quote

[6]

romain_becket
Subscriber
March 13th, 2009 at 9:53 am

Good morning,
I also try :
if(isset($_POST['AutosID'])){
$autosID=$_POST['AutosID'];
$post_id_destis=get_post($autosID);
$destis = $post_id_destis->post_author;
function metaauteur($post_ID){
add_meta_value($post_ID,’Destis’,$destis);
}
return $post_ID;
add_action(‘publish_post’,'metaauteur’);

}
but it still doesn’t work.

Permalink | Quote

[7]

Mark Cunningham
Administrator
March 13th, 2009 at 5:38 pm

As I mentioned in the other topic, trying adding some debug. You could do something like this (this would export the contents of get_post so you could see if it’s really getting a post):

$post_data = @get_post($autosID);
echo var_export($post_data,true);

(don’t forget the <php and ?> around any code!)

Permalink | Quote

[8]

romain_becket
Subscriber
March 16th, 2009 at 9:23 am

Good morning Mark, and thanks for your help.
I add a piece this piece of code a $autosID is well displayed but the meta_value isn’t added to the database.

Best regards.

Permalink | Quote

[9]

Mark Cunningham
Administrator
March 19th, 2009 at 11:36 am

Its progress! So $autosID is displayed and the post data is also valid?

Permalink | Quote

[10]

romain_becket
Subscriber
March 19th, 2009 at 4:51 pm

Yes Mark, exactly.
Everything is valid but add_meta_value($post_ID,’Destis’,$destis) doesn’t work because $post_ID is egal to 0 for now (because the post isn’t publish for now)
br

Permalink | Quote

[11]

Mark Cunningham
Administrator
March 23rd, 2009 at 1:17 pm

Actually ‘0′ is an invalid value for post id. It’ll be rejected everywhere. If a post is in draft it will have a valid post_id.

Please be aware that the ID of the post being processed can be accessed via $post_id (and not $post_ID). Perhaps this is why $post_ID is zero for you. Try it with $post_id (all lowercase)

Permalink | Quote

[12]

romain_becket
Subscriber
March 23rd, 2009 at 6:46 pm

Hi Mark. In fact there is two issue and you solve one of them, thank you.
The second issue is :

if i do :
if(isset($_POST['AutosID'])){
$autosID=$_POST['AutosID']; }
in a “text widget”, there is no problem, $autosID is set to AutosID (for example ‘6′) what I want.

But if I paste the same piece of code in a “Append to post content widget”, $autosID isn’ t set to AutosID.
It seems that i can’t get value from my previous page in “Append to post content widget”.
What can I do to retrieve my value ?
br
Romain

Permalink | Quote

[13]

Mark Cunningham
Administrator
March 30th, 2009 at 10:24 am

Try “$_REQUEST” instead of “$_POST” or if that fails, try “$post_args”. Normally all the data in $_POST or $_REQUEST gets copied into $post_args for widgets so they can be agnostic to how the form is submitted (i.e. ajax or normal POST operation). $post_args should be available in Append to post content widget.

Permalink | Quote

[14]

romain_becket
Subscriber
March 31st, 2009 at 1:10 pm

Thanks for your suggestion Mark,
Neither $autosID=$_REQUEST['AutosID']; nor $autosID=$post_args['AutosID']; works.
br

Permalink | Quote

[15]

romain_becket
Subscriber
April 1st, 2009 at 8:58 am

$autosID=$_REQUEST['AutosID']; works in “text widget” but not in “Append to post content widget”
$autosID=$post_args['AutosID']; doesn’t work in “text widget” and in “Append to post content widget”
br
Romain

Permalink | Quote

[16]

Mark Cunningham
Administrator
April 1st, 2009 at 4:15 pm

Arg! Silly me. Of course it won’t work.

Yes, it’ll appear in the “text widget” because the text widget processes when the form displays. However when you submit the form “AutosID” is lost, it’s not submitted to the backend so “Append to post content” widget never sees it.

What you need to do is something like this. Create a text widget and give it this code:

<div><input type='hidden' name='AutosID' id='AutosID' value='<?php echo $_REQUEST['AutosID']; ?>' /></div>

This’ll add an extra “input” to your form. Then with the Append to post content widget, $autosID=$post_args['AutosID'] should work as AutosID is now a genuine input.

Permalink | Quote

[17]

romain_becket
Subscriber
April 2nd, 2009 at 11:01 am

Halleluia, halleluia… :)

I just replace ‘ by ” :
<input type=”hidden” name=”AutosID” id=”AutosID” value=”" >

and then it works!
Thanks you very much! Really! I am your fan.

Permalink | Quote

[18]

Mark Cunningham
Administrator
April 21st, 2009 at 11:36 am

I’m just glad we got it work – it seemed a trivial thing but I forgot the little details of it. :)

Permalink | Quote

[19]

Dani Salvat
Subscriber
September 13th, 2009 at 1:30 pm

Hi Mark,

I was just trying to do something similar to what is Romain doing. I just want to update a data base table on submit. I’m using the Append to Post Content widget and I want to use my own PHP Classes to call some functions and method.

Is that possible?

Thank You very much.

Permalink | Quote

[20]

Sandy
Subscriber
November 18th, 2009 at 4:09 am

Mark,

I am trying to create my own captcha widget, and i’ve already got the code for the main captcha. I would just like to know how to create a widget for it that would display the image and textbox, and how to validate the input. Something that would just tell me how to create a widget that is pluggable into tdo-mini-forms.

Thanks for your time.

Permalink | Quote

Advertisments

Join the Discussion