• Hello,

    In my BuddyPress theme (Nitty Gritte Music theme) the links to Profile and Change password go to …/wp-admin/profile.php, when I am in my view of the Membership-account. This page is built by MembershipsPro functions.
    In the theme, at Members, I can reach the user fields to change etc, without going to the wp-admin/profile.php. I stay in the theme environment.

    I want my users, members, always to go to the Profile environment of the theme.
    Now I have found a lot of suggestions and solutions based upon the redirect() of WP.
    Something like this should work:
    ===========================================================
    function fb_redirect_2() {

    if ( preg_match(‘#wp-admin/?(index.php)?$#’, $_SERVER[‘REQUEST_URI’]) ) {
    if ( function_exists(‘admin_url’) ) {
    wp_redirect( admin_url(‘edit-comments.php’) );
    } else {
    wp_redirect( get_option(‘siteurl’) . ‘/wp-admin/’ . ‘edit-comments.php’ );
    }
    }
    }
    if ( is_admin() )
    add_action( ‘admin_menu’, ‘fb_redirect_2’ );
    ========================================================
    It works partially, because admins go to the wp-admin/profile with this code and logged-in users go to the homepage instead of the wp-admin/profile.php (wp environment).
    So far so good.

    But I want my logged in users always to go to the profile pages of the theme, so they can adjust the profile within the theme and not in the wp-environment.
    This is an issue that I see a lot.

    I want my redirect to go to a dynamic url.
    So I need to build my url, based upon the userinfo.

    So I tried something like:
    global $userinfo;
    getuserinfo()
    wp_redirect( get_option(‘siteurl’) . ‘/members/’ . $userinfo->user_name . ‘/profile/’ );exit();

    But whatever I try, admins go to the admins environment of WP, which is great.
    And logged in users always go to the home page of the website.
    Which is not great.

    I put this code as a function in functions.php in my child theme.

    Does anyone know how to solve this, eg with alteratives?

    Thanks!

    Pieter

  • The topic ‘Redirect users to some other url than wp-admin/profile’ is closed to new replies.