WordPress.org

Ready to get started?Download WordPress

Forums

WP User Frontend
[resolved] redirecting after posting (28 posts)

  1. globalreporter
    Member
    Posted 2 years ago #

    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?

    http://wordpress.org/extend/plugins/wp-user-frontend/

  2. Tareq Hasan
    Member
    Plugin Author

    Posted 2 years ago #

    I think currently it redirects to that new post.

  3. globalreporter
    Member
    Posted 2 years ago #

    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 page

  4. Tareq Hasan
    Member
    Plugin Author

    Posted 2 years ago #

    function 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.

  5. globalreporter
    Member
    Posted 2 years ago #

    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?

  6. Tareq Hasan
    Member
    Plugin Author

    Posted 2 years ago #

    I just tested, it works here.

    I said to paste this block of code in your current themes functions.php file, if you did that, it should work fine.

  7. nvcmedia
    Member
    Posted 2 years ago #

    How do I tweak this to redirect to a different page?

  8. nvcmedia
    Member
    Posted 2 years ago #

    Answered my own question:

    return get_permalink( $post->ID=270 )

    Or whatever the post/page ID is.

  9. gijigogo
    Member
    Posted 2 years ago #

    Thank you! Exactly what I needed. However I think this should be added as a feature in the future plugin releases.

  10. absolutex
    Member
    Posted 2 years ago #

    Thanks.

  11. Daedalon
    Member
    Posted 2 years ago #

    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?

  12. Prakash Upadhyay
    Member
    Posted 1 year ago #

    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.

  13. Prakash Upadhyay
    Member
    Posted 1 year ago #

    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 name

    Plz suggest the code to pass by pagename or postname

  14. staceym
    Member
    Posted 1 year ago #

    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');
  15. Daedalon
    Member
    Posted 1 year ago #

    Thanks staceym!

  16. professor99
    Member
    Posted 1 year ago #

    Update on this here Close Button and return on Post

  17. adnan0777
    Member
    Posted 1 year ago #

    Hi, I used this code snippet to redirect users to my desired page after they submit their posts.

    function custom_redirect( $url ) {
        global $post;
    
        return get_permalink( $post->ID=8);
    }
    add_filter( 'wpuf_after_post_redirect', 'custom_redirect' );

    But instead of implementing this code to the theme's function.php file, I had to implement this to wpuf-functions.php of the plug in file. Here 8 could be replaced by your desired page or post ID number. In my case, 8 is the page ID of Dashboard page of users.

  18. wombat86
    Member
    Posted 1 year ago #

    Is there a way to redirect users after they edit a post? Currently it shows the edit post form, and I would like them to be redirected to their post.

  19. professor99
    Member
    Posted 1 year ago #

    Hi wombat86. Try editing the code using the examples above, the notes in Close Button and return on Post and code in the development version to achieve what you want.

    I think there was also some mention of this elsewhere in the forums. Do a search for: "WP USer Frontend" "redirect"

  20. ajamm
    Member
    Posted 1 year ago #

    I cant find any frontend user editing option? am I missing a shortcode or something?

  21. adnan0777
    Member
    Posted 1 year ago #

    frontend user editing option can be turned on or off by changing plugin settings in the dashboard.

  22. ajamm
    Member
    Posted 1 year ago #

    Where? I think I have checked every screen about a dozen times each!

  23. adnan0777
    Member
    Posted 1 year ago #

    Hi ajamm,

    First you have to create a page named 'edit' or something like that and then you have to put the short code [wpuf_editpost] in that page. After that, go to WP User Frontend settings from the wordpress dashboard. Go to the 'others' tab. Look for the option, 'user can edit post?' select 'yes' or 'no' from the drop down list. Look for the option 'edit page' and then locate the edit page there (select the page where you used this short code [wpuf_editpost]). After that save the changes. If you follow the steps accurately then users should be able to edit their post from the front end. Hope that helped.

  24. ajamm
    Member
    Posted 1 year ago #

    @adnan,

    Sorry I see that you have missed what I was after, probably I wasnt very clear.

    I want to be able to edit the USERS - add/remove, see and change subscriptions etc.

    The feature list includes Admins can manage their users from frontend and I cannot find how to use this feature.

    Thankyou for taking the time to help.

  25. wombat86
    Member
    Posted 1 year ago #

    I am still not able to get this to work when adding a new post.

    It looks like when I click Submit, the new post isn't yet saved as a $post object, and I think this is why the redirect isn't working.

    I tried adding var_dump($post); in my custom redirect function and it shows "post_name"]=> string(8) "new-post"
    and it also shows my post id is 109, which is the id of my new-post page, NOT the id of the new post I just submitted.

    Shouldn't this object show the information in the post I just submitted, and not the information about the Add new post page?

    My permalinks are set up to be the post name not the id if that makes any difference.

    Thank you for the help! I hope that made sense!

  26. wombat86
    Member
    Posted 1 year ago #

    I figured out a workaround, but my last question still stands.

    I added

    if ( $post_id ) {
    $permalink = get_permalink( $post_id );
     wp_redirect( $permalink );
    exit;
    }

    to the end of wpuf-add-post.php and wpuf-edit-post.php

  27. Skalibur1
    Member
    Posted 1 year ago #

    The Tareq code Work well to me. I put redirect to my Category name :)

    Thanks Tareq!!

    /***
     * Change the direction url
     *
     * @uses <code>wpuf_after_post_redirect</code> filter hook
     *
     * @param string $url the redirection url
     * return string new redirect url
     */
    function wpufe_force_redirection( $url ) {
        return home_url('../categoryname/');
    }
    add_filter( 'wpuf_after_post_redirect', 'wpufe_force_redirection' );
  28. wombat86
    Member
    Posted 1 year ago #

    After a post is submitted and the user is redirected to that post, I am trying to echo a message on the page they are redirected to, but I can't get it to work.

    The redirect part works fine, but I can't get it to echo anything on the page they are redirected to. How can I achieve this?

    This is the code I am using in wpuf-add-post.php:

    if ( $post_id ) {
    $permalink = get_permalink( $post_id );
     wp_redirect( $permalink );
    echo 'Post published succesfully';
    exit;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic