Jump to content

code to link back to user profile on multisite


jimwise68

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.

:)

 

Link to comment
Share on other sites

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   :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.