I really need your help, please. I’ve contacted Memberpress and they can’t assist me. I’m getting a “too many redirects” message because the Profile Completion is competing with Memberpress’s redirect after sign up.
I used the below code that I found in another post. It worked for about 2 hours and then it stopped working.
function buddydev_custom_skip_check( $skip ) {
if ( is_page( ‘create-public-post’ ) ) {
$skip = false;
} elseif ( ! is_buddypress() || bp_is_members_directory() ) {
$skip = true;
}return $skip;
}add_filter( ‘bp_force_profile_completion_skip_check’, ‘buddydev_custom_skip_check’ );
function buddydev_custom_redirect() {
if ( ! is_user_logged_in() || is_super_admin() || ! function_exists( ‘bp_follow_total_follow_counts’ ) ) {
return;
}// Return if we are on welcome page
if ( is_page( ‘welcome’ ) ) {
return;
}$count = bp_follow_total_follow_counts( array( ‘user_id’ => get_current_user_id() ) );
if ( $count[‘following’] < 7 && ! bp_is_members_directory() ) {
bp_core_add_message( __( ‘Please follow atleast 7 members to continue.’, ‘buddypress’ ) );
$location = bp_get_members_directory_permalink();
header( ‘location:’ . $location );
exit;
}
}add_action( ‘bp_template_redirect’, ‘buddydev_custom_redirect’ );
Hi,
I am sorry for the trouble.The problem is we can not help you unless you provide us the code to check condition for the page to skip. MemberPress is a paid plugin(Ours is free and they have access but we don’t have access to theirs).
At least get that part from the MemberPress support. I will be happy to assist with code once you can provide us the code to check which page should be skipped.
Thank you
BrajeshThank you! They said:
They can try using the following code to override the URL so they can apply the logic to the code to redirect users to a different page than the Thank you page. It can’t be just ignored and return nothing.
add_filter(‘mepr-thankyou-page-url’, function($url, $args) {
// Replace the condition below or remove it completely to redirect to different URL
// for all signups
if( isset($_POST[‘mepr_product_id’]) && (int) $_POST[‘mepr_product_id’] == 123 ) {
return ‘https://cool-domain.com/basic-course/’;
}
return $url;
}, 10, 2);The code should be added within the WPCode plugin https://memberpress.com/docs/how-to-add-custom-code-snippets-in-wpcode/
Hi,
I am sorry, It still does not answer my question.
How do I know which page to be skipped, what is the function/code that says this is the page, and I can hook to our code.Regards
BrajeshHere is what they said:
In the first message they said:
“I am using a Profile Completion plugin. It redirects user to their profile after sign up and forces them to complete fields before accessing other pages.”
Does that mean that they want to stop redirecting users to the Thank you page and redirect all users to the profile page? In that case they can use this code:
add_filter(‘mepr-thankyou-page-url’, function($url, $args) {
return ‘https://cool-domain.com/profile-page/’; // Replace it with the URL to Profile page
}, 10, 2);If they want to have a condition to check if this is a Thank you page redirection during checkout, here’s the condition:
if( isset($_POST[‘mepr_product_id’]) ) {
// It’s a checkout request so you can catch it to skip redirection
}After that, I asked:
Could you please tell ask how about if they want to stop the redirection entirely? I think he wants the redirect code that he can look for it to make it work with his code.Then, they said:
When you are using the MemberPress checkout process, it requires users to be redirected to some page (we call it the Thank you page, but it might be any page). That’s why you can use the hook from the previous message to redirect to the chosen page. There’s no way to stop redirection entirely, unfortunately.Hi,
I am sorry, It seems their support is not able to understand the question.Simplify the question for them:-
– Is there a function to check if we are on thank you page. Like is_page(‘xyz’) but specific to memberpress? We need the code to check when we are on the thank you page, can you provide that?
I believe they should be able to understand it and help with the code.
regards
BrajeshHello – I sent them your reply and they said this:
Thank you page is a WP page. We add special content to this page, but even though we don’t have a specific function to check for a thank you page, however, you can still check if it’s a page via is_page function.
I asked this:
Okay, so you don’t know what they name of the page is? Would it not be thank you?They replied with this:
According to is_page documentation: https://developer.wordpress.org/reference/functions/is_page/ page ID is one of the supported so you can use a function in this way and check for its ID ( id for the thank you page)
is_page(346)END
I checked and my thank you page ID is 1401
Thank you.
In that case the following code will avoid redirection.
/** * Do not redirect on page 1401. */ add_filter( 'bp_force_profile_completion_skip_check', function ( $skip ) { if ( is_page( 1401 ) ) { $skip = true; } return $skip; } );
Regards
Brajesh
You must be logged in to reply to this topic.