Jump to content

Recommended Posts

This is probably a very simple fix for someone but I can't get it to work.

I have a wordpress multisite using a bought theme (which has a basic chat function) and a bought chatroom plugin. The theme and plugin clash and the result is a couple of functionalities on the theme don't work. As a work around I crated the multisite so everything works as it should.

the problem I have is when trying to go back to main site from sub-site to access user profile.

I have found this piece of code, which apparently should work but it doesnt.

Can anybody throw any light onto why not.

 

<?php $current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
    wp_redirect( 'https://mysite.co.uk/profile/'.$current_user->user_login.);  class="button"><?php _e('My Profile', 'mytheme'); ?>
    exit;
} else {
    echo "https://mysite.co.uk";
}
?>

 

the profile page url is made on the fly and is listed as: https://mysite.co.uk/profile/username

 

Any help greatly appreciated it.

:)

 

Hi Requinix

that solved it, i edited my code to:

 

    <div>
    <?php $current_user = wp_get_current_user(); ?>
    <a href="https://mainsite.co.uk/profile/<?=$current_user->user_login?>" class="button primary"><?php _e('My Profile', 'mytheme'); ?></a>
    </div>

 

...and it works perfectly   :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.