• Ariyan

    (@ariyan0282)


    I would like to know if there any way to redirect the user after saving profile details to a custom pages set by any wordpress function or UM Settins.

Viewing 13 replies - 1 through 13 (of 13 total)
  • missveronica

    (@missveronicatv)

    @ariyan0282

    You can set “Set Custom Redirect URL” in the “Registration options” for the Role you have assigned as Registration Form Role.

    https://docs.ultimatemember.com/article/103-user-roles-settings#registration-options

    https://docs.ultimatemember.com/article/87-adding-a-registration-form

    Thread Starter Ariyan

    (@ariyan0282)

    Thank You for your reply. but I want to redirect the user after saving the profile details. The profile page. https://example.com/demouser/user?um_action=edit from this page.

    missveronica

    (@missveronicatv)

    @ariyan0282

    You can try this code snippet and add your URL to the return statement.

    add_filter( 'um_update_profile_redirect_after', 'um_update_profile_redirect_another_page', 10, 3 );
    
    function um_update_profile_redirect_another_page( $url, $user_id, $args ){
    
        return 'to_another_page';
    }

    Install the code snippet into your active theme’s functions.php file
    or use the “Code Snippets” plugin.

    https://www.ads-software.com/plugins/code-snippets/

    Thread Starter Ariyan

    (@ariyan0282)

    Check the code..

    add_filter( 'um_update_profile_redirect_after', 'um_update_profile_redirect_another_page', 10, 3 );
    
    function um_update_profile_redirect_another_page( $url, $user_id, $args ){
    
        return 'https://www.google.com';
    }

    Not working!

    missveronica

    (@missveronicatv)

    @ariyan0282

    For an external web site replace the return statement with:

    exit( wp_redirect( 'https://google.com' ) );

    Thread Starter Ariyan

    (@ariyan0282)

    Okay, It’s not working if the profile edit page is in a iframe.

    and second can it be more specific for different profile forms. I have 3 profile forms so can it be more specific by their ID.

    missveronica

    (@missveronicatv)

    @ariyan0282

    Yes, you can test for the Form ID with $args['form_id']

    Thread Starter Ariyan

    (@ariyan0282)

    1. Okay, But it’s not working in iframe. So is there any solution for it.
    2. Can you share the full code if I want to redirect to an internal page ” /app/saved ” with mentioning the form id “3636”
    • This reply was modified 1 year ago by Ariyan.
    missveronica

    (@missveronicatv)

    @ariyan0282

    Redirects within an iframe you must use JavaScript.

    window.parent.location.href = "https://google.com";

    Thread Starter Ariyan

    (@ariyan0282)

    Can you share the complete code with all the changes ( form id, redirect )

    • This reply was modified 1 year ago by Ariyan.
    Plugin Support andrewshu

    (@andrewshu)

    Hello @ariyan0282

    Unfortunately, this functionality does not exist in our plugin at this time. Sorry, but customizations are not included in our support.

    Regards.

    Plugin Support andrewshu

    (@andrewshu)

    Hi @ariyan0282

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards

    Thread Starter Ariyan

    (@ariyan0282)

    Hello @missveronicatv

    I have created my code, It used to work but now its not working, if there’s any error. If I deactivate the edit form should redirect to author page. But its not redirecting to author page for subscriber roles.

    
    add_filter('um_update_profile_redirect_after', 'um_update_profile_redirect_custom', 10, 3);
    
    function um_update_profile_redirect_custom($url, $user_id, $args) {
        // Check if the user has the capabilities of a "Subscriber"
        if (user_can($user_id, 'read')) { // Adjust the capability as needed
            // Get the form ID from $args
            $current_form_id = isset($args['form_id']) ? (int) $args['form_id'] : 0;
    
            // Define the redirection URLs for each form ID
            $redirect_url_3636 = '/app/saved/';
            $redirect_url_3723 = '/app/saved2/';
            $redirect_url_5990 = '/app/saved3/';
            $default_redirect_url = '/app/dashboard/';
    
            // Check the form ID and set the appropriate redirection URL
            if ($current_form_id == 3636) {
                $redirect_url = $redirect_url_3636;
            } elseif ($current_form_id == 3723) {
                $redirect_url = $redirect_url_3723;
            } elseif ($current_form_id == 5990) {
                $redirect_url = $redirect_url_5990;
            } else {
                $redirect_url = $default_redirect_url;
            }
    
            // Use wp_redirect to perform the redirection
            wp_redirect($redirect_url);
            exit();
        }
    
        return $url; // If not a subscriber, return the original URL
    }
    
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to redirect after saving profile details to a custom page.’ is closed to new replies.