<?php
if (is_user_logged_in()) {

    if (class_exists('BuddyPress') && class_exists('Youzify')) {
        $author_ID =  get_current_user_id();
        $user = get_user_by('ID', $author_ID);
        $login_page_url = get_site_url() . '/members/' . $user->user_login; ?>
<?php }
} else {?>
<?php
    if (class_exists('BuddyPress') && class_exists('Youzify')) {
        $youzify_membership_pages = get_option('youzify_membership_pages', true);
        $login_page_url = get_permalink($youzify_membership_pages['login']); ?>
<?php } ?>
<?php } ?>

<?php

wp_redirect( $login_page_url ); exit; ?>
