I'm attempting to create my very own wordpress plugin in wordpress. Everything is effective but I wish to create a loginredirect look for customers who wish to accessibility plug ins page.

Here's my function during my functions.php:

function wpuf_auth_redirect_login() {  
    $user = wp_get_current_user();  
    if ( $user->id == 0 ) {  
        nocache_headers();  
        wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));  
        exit();
    }  
}

Which is from the myplugin.php:

function wpuf_user_edit_profile() {  
    wpuf_auth_redirect_login(); // if not logged in, redirect to login page
    nocache_headers();  
    wpuf_post_form_style();  
    wpuf_user_edit_profile_form();  
} 

add_shortcode('wpuf_editprofile', 'wpuf_user_edit_profile');

It's not working. Basically go into the plug ins page like a guest in browser it doesn't redirect. It only shows web site uncomplete. Any help?