Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    What exactly doesn’t work?

    Thread Starter promoplanet

    (@promoplanet)

    When I click “Switch User” as the admin, it redirects to the home page of the site, and the admin is still logged in

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Sorry to hear that. Can you try deactivating your other plugins one by one to see which one is causing the problem?

    Thread Starter promoplanet

    (@promoplanet)

    It’s not the plugin, I did the deactivation isolation test, and I figured out it’s the code snippets I have uploaded, it’s more of these 10 snippets below. Can you read the CONTENTS list just let me know your best guest of which one is interfering, just to save me time. I imagine it’s one that affects the user login URL?

    /** CONTENTS OF SNIPPETS
    *
    * 1. Add “Change Cover” to profile account menu.
    * 2. Add Notifications & Messages Nav Menu Counts.
    * 3. Redirect “wp-login.php” Page To Youzer Login Page.
    * 4. Change “Widgets Settings” to “Overview Settings”
    * 5. Redirect User After Registration
    * 6. Enable Facebook Link Style : http://www.yourwebsite.com/username
    * 7. Set Change avatar as default page for the profile settings
    * 8. Redirect Logged-in Users from Home Page to Their Profile
    * 9. Force Buddypress Covers Activation.
    * 10. Replace “{username}” by the current logged-in user name.
    */

    /**
    * 1. Add “Change Cover” to profile account menu.
    */
    function yz_add_change_cover_to_profile_account_menu( $links ) {
    if ( ! function_exists( ‘youzer_is_active’ ) ) {
    return false;
    }

    // Change Cover Link
    $links[‘change-cover-image’] = array(
    ‘icon’ => ‘far fa-image’,
    ‘href’ => yz_get_profile_settings_url( ‘change-cover-image’ ),
    ‘title’ => __( ‘Change Cover’, ‘youzer’ )
    );
    return $links;
    }
    add_filter( ‘yz_get_profile_account_menu’, ‘yz_add_change_cover_to_profile_account_menu’ );

    /**
    * 2. Add Notifications & Messages Nav Menu Counts.
    */
    function yzc_notifications_and_messages_nav_menu_count( $items ) {
    // Set up Array’s.
    foreach( $items as $key => $item ) {

    // if user logged-in change the Login Page title to Logout.
    if ( strcasecmp( $item->title, ‘notifications’ ) == 0 ) {
    // Get user Notifications
    $notifications_count = bp_notifications_get_unread_notification_count();
    if ( $notifications_count <= 0 ) {
    continue;
    }
    $item->title .= ‘<span class=”yz-nav-count” style=”margin-left: 8px; min-width: 30px; height: 30px; display: inline-block; color: #fff; text-align: center; line-height: 30px; background-color: #FFC107; border-radius: 100%;”>’. $notifications_count . ‘</span>’;

    } elseif( strcasecmp( $item->title, ‘messages’ ) == 0 ) {

    $msgs_count = bp_get_total_unread_messages_count();

    if ( $msgs_count <= 0 ) {
    continue;
    }
    $item->title .= ‘<span class=”yz-nav-count” style=”margin-left: 8px; min-width: 30px; height: 30px; display: inline-block; color: #fff; text-align: center; line-height: 30px; background-color: #f95e3c; border-radius: 100%;”>’. $msgs_count . ‘</span>’;
    }
    }
    return $items;
    }
    add_filter( ‘wp_nav_menu_objects’, ‘yzc_notifications_and_messages_nav_menu_count’, 10 );

    /**
    * 3. Redirect “wp-login.php” Page To Youzer Login Page.
    */
    function yz_redirect_wplogin_to_youzer_login_page() {

    if ( ! yz_is_membership_system_active() ) {
    return false;
    }

    if ( isset( $_GET[‘action’] ) && ( $_GET[‘action’] == ‘logout’ || $_GET[‘action’] == ‘lostpassword’ || $_GET[‘action’] == ‘bp-resend-activation’ ) ) {
    return;
    }
    global $pagenow;

    if ( ‘wp-login.php’ == $pagenow && $_SERVER[‘REQUEST_METHOD’] == ‘GET’ ) {
    // Get Login Page Url.
    $login_url = yz_get_login_page_url();
    // Redirect !!
    wp_redirect( $login_url );
    exit();
    }
    }
    add_action( ‘init’, ‘yz_redirect_wplogin_to_youzer_login_page’ );

    /**
    * 4. Change “Widgets Settings” to “Overview Settings”
    */
    function yz_translate_youzer_text( $translated_text ) {
    switch ( $translated_text ) {
    case ‘widgets settings’ :
    $translated_text = __( ‘Overview Settings’, ‘youzer’ );
    break;
    }

    return $translated_text;
    }
    add_filter( ‘gettext’, ‘yz_translate_youzer_text’, 10 );

    /**
    * 5. Redirect User After Registration
    */
    //function yzc_redirect_after_registration($user) {
    // $redirect_url = ‘www.kainelabs.com’;
    // bp_core_redirect( $redirect_url );
    //}
    //add_action( ‘bp_core_signup_user’, ‘yzc_redirect_after_registration’, 100, 1 );

    /**
    * 6. Enable Facebook Link Style : http://www.yourwebsite.com/username
    * Enable Root Profiles .
    */
    define ( ‘BP_ENABLE_ROOT_PROFILES’, true );
    add_filter( ‘bp_core_enable_root_profiles’, ‘__return_true’ );

    /**
    * 7. Set Change avatar as default page for the profile settings
    */
    function yz_set_profile_change_avatar_as_default_nav( $default_tab ) {
    return ‘change-avatar’;
    }
    add_filter( ‘yz_profile_settings_default_tab’, ‘yz_set_profile_change_avatar_as_default_nav’ );

    /**
    * 8. Redirect Logged-in Users from Home Page to Their Profile
    *
    *function yz_redirect_loggedin_user_from_home_to_profile() {
    *
    * if ( is_user_logged_in() && ( is_home() || is_front_page() ) ) {
    * wp_redirect( bp_loggedin_user_domain() );
    * exit;
    * }
    *
    *}
    */

    add_action( ‘template_redirect’, ‘yz_redirect_loggedin_user_from_home_to_profile’ );

    /**
    * 9. Force Buddypress Covers Activation.
    */
    function youzer_activate_buddypress_covers() {
    return true;
    }

    add_filter( ‘bp_is_profile_cover_image_active’, ‘youzer_activate_buddypress_covers’, 999 );
    add_filter( ‘bp_is_groups_cover_image_active’, ‘youzer_activate_buddypress_covers’, 999 );

    /**
    * 10. Replace “{username}” by the current logged-in user name.
    */
    function yzc_replace_username_variable( $url ) {

    // Get Profile User Id.
    $user_id = bp_core_get_username( bp_loggedin_user_id() );

    $url = str_replace( ‘{username}’, $user_id, $url );

    return $url;
    }

    add_filter( ‘esig_url_redirect’, ‘yzc_replace_username_variable’ );

    ?>

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    It’s most likely number 3. If not, you can try removing code snippets one by one to see if you can find the culprit!

    Best of luck finding the problem.

    Thread Starter promoplanet

    (@promoplanet)

    It is number 3! Thanks for helping! Wow great support, really appreciate it. Got it to work finally.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Plugin Does Not Work’ is closed to new replies.