• how can I get the current user ID to show up where it say “CURRENT USER ID HERE” when the person click on the link in this code?

    if ($profile_link[$user_role] == true) :
                        $profile_url = $this->GetOption('profile_url');
                        $profile_url = (!empty($profile_url)) ? $profile_url : ('/?page_id=20&profile-edit=CURRENT USER ID HERE');
                    echo '<li><a href="' . $profile_url . '">' . __('Profile', 'simpelogin') . '</a></li>' . "\n";
                    endif;

Viewing 4 replies - 1 through 4 (of 4 total)
  • This will get you the current user ID:

    global $current_user;
    
    $current_user = wp_get_current_user();

    Then, you can use $current_user->ID where you want.

    Thread Starter Quan_master

    (@quan_master)

    Do i just put that code in that spot then? sorry for such stupid questions.. as you can tell I am not a php coder at all, I just sorta look at code and try and understand it.

    Thread Starter Quan_master

    (@quan_master)

    I tried this but it still didn’t work the code just shows up as well in the link

    function DoSimpleLogin($args = '') {
                global $user_ID, $current_user, $login_errors, $user_level;
                $current_user = wp_get_current_user();
    get_currentuserinfo();
    
                extract ($args);
    
                if ($user_ID != '') {
                    require_once (ABSPATH . '/wp-admin/includes/upgrade.php');
                    $user_role = translate_level_to_role($user_level);
                    $dashboard_link = $this->GetOption('dashboard_link');
                    $profile_link = $this->GetOption('profile_link');
                    echo $before_widget . $before_title . __('Welcome', 'simpelogin') . ', ' . $current_user->display_name . $after_title . "\n";
    sf_pm_tag(true, false);
                    if ($this->GetOption('show_gravatar') == true) :
                        echo '<div class="simplelogin-avatar">' . get_avatar( $user_ID, $size = $this->GetOption('gravatar_size') ) . '</div>' . "\n";
                    endif;
                    do_action('simplelogin_avatar', $current_user);
                    echo '<ul class="simplelogin-links">' . "\n";
                    if ($dashboard_link[$user_role] == true) :
                        $dashboard_url = $this->GetOption('dashboard_url');
                        $dashboard_url = (!empty($dashboard_url)) ? $dashboard_url : admin_url();
                        echo '<li><a href="' . $dashboard_url . '">' . __('Dashboard', 'simpelogin') . '</a></li>' . "\n";
                    endif;
                    if ($profile_link[$user_role] == true) :
                        $profile_url = $this->GetOption('profile_url');
                        $profile_url = (!empty($profile_url)) ? $profile_url : ('/?page_id=20&profile-edit=($current_user->ID)');
                    echo '<li><a href="' . $profile_url . '">' . __('Profile', 'simpelogin') . '</a></li>' . "\n";
                    endif;

    Any help would be appreciated.

    $profile_url = !empty($profile_url) ? $profile_url : '/?page_id=20&profile-edit='.$current_user->ID;

    I think you meant to put curly brackets {} instead of () around the variable there, but even then, those only work inside double quotes, not single.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Getting Current User ID’ is closed to new replies.