[Plugin: WP User Frontend] redirecting after posting
-
I would like users be redirected to the current page rather than to their post page, after posting. Is there a way to do that through the settings or tweaking the php code?
-
I think currently it redirects to that new post.
You answered “I think currently it redirects to that new post”.
Exactly, this what happens now. But I would like rather have a redirecting to the current post, not to the new post, so my users can make new posts without leaving the posting pagefunction custom_redirect( $url ) { global $post; return get_permalink( $post->ID ); } add_filter( 'wpuf_after_post_redirect', 'custom_redirect' );Try this code, insert this function in your themes functions.php. Should work, not tested.
I tried but nothing changed. Shall I just insert the code you wrote or do i need to add some other code elements by myself?
I just tested, it works here.
I said to paste this block of code in your current themes
functions.phpfile, if you did that, it should work fine.How do I tweak this to redirect to a different page?
Answered my own question:
return get_permalink( $post->ID=270 )Or whatever the post/page ID is.
Thank you! Exactly what I needed. However I think this should be added as a feature in the future plugin releases.
Thanks.
It could be useful to have this as a setting with the following options:
After posting, redirect user to:
- The post they just submitted
- Back to the same page they were on when submitting
- This page: [Dropdown list of pages]
- The post or page with the following ID: [ ]
- A custom URL: [ ]
I’d personally use the second setting of redirecting back to whichever page the user submitted the form on. This is good when the form is placed on more than one different page – for example to have different pages with different forms for different content types (eg. Events, Locations). If the user submitted a new Event, they can now submit another Event without any extra clicks.
Also adding an option to customize this per form could come in handy. For example like this:
[wpuf_addpost redirect_after="VALUE"], where VALUE would be either:- 0, to return back to the same page,
- a post or page ID, or
- a custom URL.
What do you guys think, would this be what you’re hoping for?
Tareq: Could you consider implementing this?
Hi,
Thanks for the above code its works well to be on the same page after submitting new post. But It should show some message after the post being successfully submitted.so Please help me to write the code,to show my custom message that should display after the new post submit on the same page.
hello,
the above code you have mentioned is for passing the Post ID or Page ID
return get_permalink( $post->ID=270 )
but instead of passing the ID can we pass the postname
or Page namePlz suggest the code to pass by pagename or postname
If you want to redirect after post submission, put this in your theme file:
// Change redirect page after submission function my_after_post_redirect() { $URI = 'http://www.mydomain.com/my-custom-redirect/'; return $URI; } add_filter('wpuf_after_post_redirect', 'my_after_post_redirect');Thanks staceym!
Update on this here Close Button and return on Post
The topic ‘[Plugin: WP User Frontend] redirecting after posting’ is closed to new replies.