Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: redirecting to user domain using $bp


shaisimchi
Participant

@shaisimchi

i tried with the new action – same result.

here is the function:

function bp_location_redirect_to_page()
{
global $bp,$wpdb;

$redirect_url_has_location = ‘http://athleticrash.com’;
$city = $wpdb->get_var($wpdb->prepare(“SELECT value FROM wp_bp_xprofile_data WHERE user_id=%d AND field_id=26” , $bp->loggedin_user->id ));
$state = $wpdb->get_var($wpdb->prepare(“SELECT value FROM wp_bp_xprofile_data WHERE user_id=%d AND field_id=27” , $bp->loggedin_user->id ));
$country = $wpdb->get_var($wpdb->prepare(“SELECT value FROM wp_bp_xprofile_data WHERE user_id=%d AND field_id=103” , $bp->loggedin_user->id ));
$zip = $wpdb->get_var($wpdb->prepare(“SELECT value FROM wp_bp_xprofile_data WHERE user_id=%d AND field_id=23” , $bp->loggedin_user->id ));
if (!$city || $city==”)
$has_city=0;
else
$has_city=1;

if (!$state || $state==”)
$has_state=0;
else
$has_state=1;

if (!$country || $country==”)
$has_country=0;
else
$has_country=1;

if (!$zip || $zip==”)
$has_zip=0;
else
$has_zip=1;

$user_link = $bp->loggedin_user->domain;
$profile_path = ‘profile/edit’;
$redirect_url_no_location = $user_link . $profile_path;

if ($has_city==1 && $has_state==1 && $has_country==1 && $has_zip==1 )
bp_core_redirect($redirect_url_has_location);
else
bp_core_redirect($redirect_url_no_location);
}
/*Add an action to redirect user after login*/
add_action(‘login_redirect’,’bp_location_redirect_to_page’,100,0);

Skip to toolbar