8

I'm trying to figure out how to link a logged-in user to his profile settings, but I can't seem to find a function that generates this link (like wp_settings_url() or wp_profile_url()) Is there a default function for this?

15

The user edit page of the current user is /wp-admin/profile.php, so you can just do admin_url( 'profile.php' ), which is the way it is used in the WP source code.

1
  • Worked perfectly for me as well, nice elegant solution. Thanks Jan. – Lars Koudal Mar 16 '11 at 14:48
6

Combination of other answers:

<a href="<?php echo admin_url( 'user-edit.php?user_id=' . $curauth->ID, 'http' ); ?>">Edit Profile</a>

I'm using this on author.php, that's why I've already got the user ID on the page. That way an admin gets a link to edit that user's profile rather than their own.

2

Possibly something like this?

<?php get_currentuserinfo();

global $user_ID;
if (” != $user_ID) { ?>

<a href="/wp-admin/user-edit.php?user_id=<?php the_author_ID(); ?>">Edit
Profile</a>

<?php } ?>
1
  • Haven't had chance to check this out but should work! – Vince Pettit Jan 7 '11 at 12:43
1

If you're only interested in the current user, use get_edit_profile_url():

<a href="<?php esc_attr_e( get_edit_profile_url() ); ?>">
    <?php esc_html_e( 'Link to your profile' ); ?>
</a>

If you want to display a link to another user's profile, use get_edit_user_link():

<?php
$user = get_userdata( $user_id );
if ( $user ):
    ?>
    <a href="<?php esc_attr_e( get_edit_user_link( $user->ID ) ); ?>">
        <?php esc_html_e( $user->user_login ); ?>
    </a>
    <?php
endif;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.