create redirection to custom page at a button

hey! Please enter this page: http://team.marbergs.com/setup/register/
I am about to create my own setup wizard, and when someone has registered themself at this url I want to "register" button to redirect them to another page. Is this possible with some coding?

greetings, Marcus

ps, I grant you access

  • Predrag Dubajic

    Hey Marcus,

    Hope you're doing well today :slight_smile:

    Usually the registration page should redirect to Thank You Page selected in Membership 2 settings but for some reason this is not working on your site as it should, it could be that one of your plugins is interfering with M2 registration process.

    You could try checking for conflicts by disabling your other themes and switching to default wp theme to see how it behaves after that.

    Also, you can try adding this code to your child theme functions.php file:

    function wpse_19692_registration_redirect() {
        return 'Your full page url goes here';
    }
    
    add_filter( 'registration_redirect', 'wpse_19692_registration_redirect' );

    Just change Your full page url goes here with URL to desired page.

    Best regards,
    Predrag

  • MarcuSM

    hm.. the code didnt work. anyways, I found the code where the redirection is in the plugin that I am using. here it is:

    wppb_custom_redirect_url( 'after_login', $redirect_to, $user );
    
    					if( ! empty( $redirect_url ) ) {
    						$redirect_to = $redirect_url;
    					}
    				}
    			}
                $redirect_to = apply_filters( 'wppb_after_login_redirect_url', $redirect_to );
    		}
    	}
    
    	return $redirect_to;
    }
    add_filter( 'login_redirect', 'wppb_login_redirect', 10, 3 );

    Is there any way to make this custom redirection?

    I would also like to change the redirection in this code to a custom url:

    wppb_custom_redirect_url( 'after_success_email_confirmation', '', $user_login );
    				}
    			}
    			$redirect_url = apply_filters( 'wppb_success_email_confirmation_redirect_url', $redirect_url );
    			$wppb_cr_delay = apply_filters( 'wppb_success_email_confirmation_redirect_delay', $wppb_cr_delay = 5 );
    
    			$success_message = apply_filters( 'wppb_success_email_confirmation', '<p class="wppb-success">' . __( 'Your email was successfully confirmed.', 'profile-builder' ) . '</p><!-- .success -->' );
                $admin_approval_message = apply_filters( 'wppb_email_confirmation_with_admin_approval', '<p class="alert">' . __('Before you can access your account, an administrator needs to approve it. You will be notified via email.', 'profile-builder' ) . '</p>' );
    
    			if( ! empty( $redirect_url ) ) {
    				$wppb_cr_success_message = apply_filters( 'wppb_success_email_confirmation_redirect_message', '<p class="wppb-success">' . __( 'You will soon be redirected automatically.', 'profile-builder' ) . '</p>' ) . '<meta http-equiv="Refresh" content="'.$wppb_cr_delay.';url='.$redirect_url.'" />';
    			}

    Thanks a lot for the great support!! <3

  • Adam Czajczyk

    Hello MarcuSM!

    The reason that membership 2 redirection don't work is because the plugin that I am using has their own redirections I guess... The redirection works great at membership 2 login form.

    This is a highly probable reason as quite likely there's a conflict. Yet, as the plugin you're using seems to be working fine (if I understand correctly) we could "hook to it" to add custom redirection. Instead however of changing plugin's core files could you try other way?

    Let me start with the first code you shared. Here's an altered version of it:

    wppb_custom_redirect_url_cust( 'after_login', $redirect_to, $user );
    
    					if( ! empty( $redirect_url ) ) {
    						$redirect_to = 'YOUR_REDIRECT_URL_HERE';
    					}
    				}
    			}
                $redirect_to = apply_filters( 'wppb_after_login_redirect_url', $redirect_to );
    		}
    	}
    
    	return $redirect_to;
    }
    add_filter( 'login_redirect', 'wppb_login_redirect_cust', 10, 2 );

    To make it work first replace YOUR_REDIRECT_URL_HERE with an URL you wish to redirect users to. Then place the code at the end of your current theme's functions.php file.

    As for the second code. It includes filters so we should be able to hook to them to:

    function wppb_custom_redirect_url_cust($redirect_url) {
    		return 'YOUR_REDIRECT_URL_HERE';
    }
    add_filter('wppb_success_email_confirmation_redirect_url', 'wppb_custom_redirect_url_cust');

    Again, please replace YOUR_REDIRECT_URL_HERE with your custom redirect target URL and add this code at the end of functions.php file of your current theme.

    Let me know please if it worked for you.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.