[wp-hackers] Frontend form

Diana K. Cury dianakac at gmail.com
Fri Aug 19 19:51:01 UTC 2011


Thanks everybody!

I solved this, not sure if the right way but it works. The nounce thing 
still a mistery, but I will  refer that.

Now, the processing code only loads whenever the shortcode is used  using 
get_header filter for load that in right time.

Also, processing form and form codes are in separated files, that seems 
easier for when adding new fields and processing.

I'm having some issue on checkboxes for taxonomies, but that is for a next 
message soon!

Thanks again



----- Original Message ----- 
From: "Dion Hulse (dd32)" <wordpress at dd32.id.au>
To: <wp-hackers at lists.automattic.com>
Sent: Thursday, August 18, 2011 11:29 PM
Subject: Re: [wp-hackers] Frontend form


Just a quick note, init would the absolute earliest you should perform
it, and in most cases, it's way too early (Other plugins init hooks
might not have been run, etc).
Generally, the template_redirect hook is the last hook run before the
template is output, and is a good generic "WordPress has loaded,
queried for the current page, and everything is set ready for output".
Init would be described as "WordPress has included all the files..
Time for plugins and other routines to start running.. After this,
we'll work  out the request that was made, query for the posts, do a
tonne of other things, and then consider outputting the template based
on what the plugins and internal routines have said"

On 19 August 2011 12:23, James Collins <james at om4.com.au> wrote:
> At the point where WordPress is rendering/loading the shortcode (ie 
> calling
> your shortcode function), your website's header HTML has already been sent
> to the browser.
>
> If you want your form submission handling code to perform a HTTP redirect,
> your form submission handling code will need to hook into something like 
> the
> 'init' hook instead of being done inside the shortcode handler function.
>
> So you have your form display/rendering code in the shortcode handler
> function, and your form submission/handler code somewhere where it gets
> executed before WordPress begins to output any HTML or HTTP headers.
>
> James
>
>
>
>
> On 19 August 2011 06:32, Florin Maduta <madutaflorin at gmail.com> wrote:
>
>> Check the files for spaces after closing php tag. I'm prety sure that 
>> this
>> is the problem
>>
>> On Thu, Aug 18, 2011 at 11:08 PM, Diana K. Cury <dianakac at gmail.com>
>> wrote:
>>
>> > Thanks for reply Eric,
>> >
>> > I will test some more and post the code soon. The most strange is if I
>> add
>> > the form and form processing code after template calls (get_header,
>> sidebars
>> > etc), I get the "headers already sent", (both for page templates or
>> > shortcode insertion). It seems something to do with template header
>> itself.
>> >
>> > The processing code should stay before all the html header, or not 
>> > really
>> > necessary?! If so, that will be a lot of filterings for get the 
>> > shortcode
>> > feature done.
>> >
>> > Quite not sure if I should implemente this in my plugin...is an one 
>> > time
>> > use form, a shortcode maybe aren't the best aproach for this isn't?!
>> >
>> > ----- Original Message ----- From: "Eric Mann" <eric at eam.me>
>> > To: <wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com
>> >>
>> > Sent: Thursday, August 18, 2011 3:18 PM
>> > Subject: Re: [wp-hackers] Frontend form
>> >
>> >
>> >
>> > We'd have to see what code you're using in the form to diagnose the
>> >> "Headers
>> >> already sent" issue, but typically this is due to either `echo`ing
>> content
>> >> too early in WP's execution or trying to modify the page headers too
>> late
>> >> in
>> >> WP's execution.
>> >>
>> >> My guess is that you're trying to use some kind of HTTP redirect 
>> >> within
>> >> the
>> >> content of the page ...
>> >>
>> >> As for preventing the browser's back button ... don't. It's bad form 
>> >> to
>> >> modify the behavior of the browser like that, and the user might have 
>> >> a
>> >> legitimate reason to use the back button. Instead, just validate the
>> form
>> >> to prevent duplicate submissions - i.e. use a nonce to detect whether 
>> >> or
>> >> not
>> >> this is a repeat submission and reject the re-submission.
>> >>
>> >> On Thu, Aug 18, 2011 at 10:51 AM, Diana K. Cury <dianakac at gmail.com>
>> >> wrote:
>> >>
>> >> I have a working frontend form, for create post types.
>> >>>
>> >>> Using as a template for pages: works nice, I'm able to create the 
>> >>> post
>> I
>> >>> get redirected to the them right after the process.
>> >>>
>> >>> When I tried to implement this form as a plugin shortcode, I got
>> "Headers
>> >>> alredy sent ". The post is created as well, but doesn't redirect to 
>> >>> the
>> >>> post.
>> >>>
>> >>> Also, is there someway to prevent going back in history and re-submit
>> the
>> >>> form again? I know there's a lot of plugin for this, but that is a 
>> >>> very
>> >>> simples static form.
>> >>> ______________________________**_________________
>> >>> wp-hackers mailing list
>> >>> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>> >>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<
>> http://lists.automattic.com/mailman/listinfo/wp-hackers>
>> >>>
>> >>> ______________________________**_________________
>> >> wp-hackers mailing list
>> >> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>> >> http://lists.automattic.com/**mailman/listinfo/wp-hackers<
>> http://lists.automattic.com/mailman/listinfo/wp-hackers>
>> >>
>> >
>> > ______________________________**_________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
>> > http://lists.automattic.com/**mailman/listinfo/wp-hackers<
>> http://lists.automattic.com/mailman/listinfo/wp-hackers>
>> >
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers 



More information about the wp-hackers mailing list