[wp-hackers] Frontend form
James Collins
james at om4.com.au
Fri Aug 19 02:23:54 UTC 2011
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
>
More information about the wp-hackers
mailing list