puzz
Forum Replies Created
-
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramHey, look, if this is only for me, don’t worry. I’m not using widgets and I’ll just change the code with
template_redirect. You can then fix this without any time pressure when (if) you find the time.Forum: Plugins
In reply to: [VS Contact Form] Submit query paramThe
template_redirectisn’t related to any http redirects:This action hook executes just before WordPress determines which template page to load.
I decided to use it (instead of
init) because at that point I’m sure that the global$postvariable is fully loaded. But if it works withinitit’s fine, too.- This reply was modified 9 years, 5 months ago by puzz.
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramAh, and there is another (and slightly better) solution. This will start
ob_start()only when it detects that the current$posthas your shortcode:add_action('template_redirect', 'vscf_check_shortcode'); function vscf_check_shortcode() { global $post; if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'contact') ) { ob_start(); } }…and now
wp_redirect()will work.Forum: Plugins
In reply to: [VS Contact Form] Submit query paramHey, here I am again, I think this should work:
add_action('init', 'do_output_buffer'); function do_output_buffer() { ob_start(); }…it makes sure no content is sent before you. The content is kept in memory and WordPress makes sure to flush all the
ob_cache later.And now
wp_redirect()(https://developer.ww.wp.xz.cn/reference/functions/wp_redirect/) can be used from any place in your plugin.I’m still reading if that is OK to do from a wp plugin, but it works.
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramI caught a bad flu last week and haven’t had the time to experiment with it. If nothing works, I’ll just have to live with it.
And, don’t worry about my donation. That was for your efforts (and nobody can deny that you work hard, I appreciate that!). If you ever come to Croatia, ping me I owe you a beer for your efforts!
- This reply was modified 9 years, 5 months ago by puzz.
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramYeah, that should work. The redirect is slow because it needs to load the page, with header redirect it would be almost instant, I suppose. But, I don’t mind if it’s slow, the only important thing for me is to have this one specified url requested (sooner or later).
BTW, the cleanest way to do the redirect properly is probably to register a hook like:
add_action('init', 'your_function');This is done before WP starts the output, and you are still in time to send a header there. But I think that would need a bigger refactoring of the code. In the meantime, the javascript redirect is definitely enough for me.
PS. Just sent a “Thank you” donation. Not huge, but I think it should be enough for a pizza and a beer (maybe even two) in Netherlands π
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramI’m not on my dev machine now, but I’ll try to experiment with it tomorrow.
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramHey, yes, that’s exactly what I was thinking.
Anyway, if you need any help just let me know.
Forum: Plugins
In reply to: [VS Contact Form] Submit query paramYes, that would be perfect!
Now, I’m not much of an wordpress developer (more into Java/Golang), but I think the normal
location()redirect can’t be done from a plugin when part of the page is already sent. At least I think it is. But maybe even a<javascript>document.location=...</javascript>will be enough?Forum: Fixing WordPress
In reply to: Blog by email posts blank in 2.3.2 w/ HTML emailWP 2.5 here… Don’t work for me π