WPUF Tip – Redirect after submission
I’ve been using WordPress User Frontend for a few days now to manage submissions here. One of the problems I had was that the form would redirect to the new post after submission. But as that submission was set to pending the users would get a no page found error and proceed to retry their submissions multiple times. Hence the up to six identical posts being submitted by users. Below is a quick fix to the WordPress User Frontend Page Submit error issue and bit extra.
Add this piece of code to your functions.php to redirect user to submission page.
|
1 2 3 4 5 6 |
function custom_redirect( $url ) { global $post; return get_permalink( $post->ID ); } add_filter( 'wpuf_after_post_redirect', 'custom_redirect' ); |
You can also redirect the user to a page or post by simply adding the page/post id to “$post->ID=X”, where “X” will be the page id.
|
1 2 3 4 5 6 |
function custom_redirect( $url ) { global $post; return get_permalink( $post->ID=X ); } add_filter( 'wpuf_after_post_redirect', 'custom_redirect' ); |
You can find your page/post id by visiting the page/post page and hovering over the title or “edit”.
