Home Forums Plugin Support WP User Frontend Pro Redirect users after posting/editing using Buddypress

This topic is: resolved

This topic contains 4 replies, has 3 voices, and was last updated by  Tareq Hasan 5 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6109

    hatchmedia
    Participant
    Post count: 116

    Hi all,

    Ok, I have a question I was hoping you would be able to help with.

    I am using WPUFPro with BuddyPress and also Theme My Login. I have four forms set up to allow users to upload Custom Posts with Taxonomies. After the user uploads/edits a custom post, I would like to redirect them back to their account to show them their posts.

    Now, I know there is a setting in each form to redirect them to either the post, same page, a different page or custom url. My issue is that because I am using BuddyPress and I need to include the username as part of the url.

    The address I want to send my users to is something like http://mysite.com/rescues/username/my-account. The ‘/rescues/username' element is added by BuddyPress and because every username is different, it means that I am unable to type out the required url.

    I am also unable to pick a specific page for the same reason. If I use the page that contains the [wpuf_dashboard] shortcode (in my case, my-pets) it will take me to http://mysite.com/my-account and omit the ‘/rescues/username' part.

    With Theme My Login, I am able to use ‘/%user-login%/' for redirections and it will retrieve the correct username. Would there be a work around like this for WPUF Pro?

    I hope all this made sense! ๐Ÿ™‚

    Thanks

    Damien

    #6112

    Tareq Hasan
    Keymaster
    Post count: 2831

    [php]
    function wpuf_redirect_to_profile( $response ) {
    $response[‘redirect_to'] = bp_core_get_user_domain( get_current_user_id() );

    return $response;
    }

    add_filter( ‘wpuf_add_post_redirect', ‘wpuf_redirect_to_profile' );
    add_filter( ‘wpuf_edit_post_redirect', ‘wpuf_redirect_to_profile' );
    [/php]

    Paste the code in your themes functions.php and set the redirect to option to a page or any URL. This code will override the URL and redirect them to the buddypress user profile and adding/editing a post.

    #6116

    hatchmedia
    Participant
    Post count: 116

    Excellent! Exactly what I was looking for!

    Yet again, great customer support Tareq!

    Damien

    #7009

    epictum
    Participant
    Post count: 23

    I'm also in a similar boat, but this function doesn't work for, most likely because the Edit page I'm trying to redirect my BP users to is one that was created manually. How would I go about redirecting one of my users from mydomain.com/edit/ to mydomain.com/members/username/movies/edit/ ?

    #7031

    Tareq Hasan
    Keymaster
    Post count: 2831

    @epictum, $response['redirect_to'] is the redirect URL. So you could put it like that:
    [php]
    $user = wp_get_current_user();
    $response[‘redirect_to'] = home_url() . ‘/members/' . $user->user_login . ‘/movies/edit';;
    [/php]

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Redirect users after posting/editing using Buddypress’ is closed to new replies.