Long term reader, first question.
I've got a custom buddypress // Wordpress 3.8.1 setup with Paid Membership Pro. The code is if you're not a premium member type 1, redirect to free member (2 or 3) page. And hide the link to the premium pages.
I've looked at the docs, but can't solve it for two problems.
I'm getting 'Warning: Division by zero' on the second if statement. I'm familiar with this with maths, but not with true/false. - Fixed by @markB
Where I have indicated , I need to link to the URL without using the static URL.
So it should redirect from '/profile/edit/group/12/' to '/profile/edit/group/1/'.
I believe the answer can be done with strpos, but I'm not familiar with it. See: Check if URL has certain string with PHP
if( bp_is_my_profile() && $loggged_in_memberships[0]->membership_id != 1) {
if ($_SERVER['HTTP_HOST'] ==
“localhost/wordpress/members/<user>/profile/edit/group/12/”) {
header("localhost/wordpress/members/<user>/profile/edit/group/1/");
}
echo "statement"
}
--Edit-- Based on comments I have modified code:
if( bp_is_my_profile() && $loggged_in_memberships[0]->membership_id != 1) {
if ($_SERVER['REQUEST_URI'] == '/members/'.$current_user->user_login.'/profile/edit/group/5/') {
global $current_user;
bp_core_redirect(get_option('siteurl').'/members/'.$current_user->user_login.'/profile/edit/group/12/');
}
Thanks in advance.