I am using a custom wordpress login form using the following code. I have this form in the sidebar of my site:

&lt;?php
if ( ! is_user_logged_in() ) { // Display WordPress login form:
    $args = array(
        'redirect' =&gt; admin_url(), 
        'form_id' =&gt; 'loginform-custom',
        'label_username' =&gt; __( 'Username' ),
        'label_password' =&gt; __( 'Password ),
        'label_remember' =&gt; __( 'Remember Me' ),
        'label_log_in' =&gt; __( 'Log In' ),
        'remember' =&gt; true
    );
    wp_login_form( $args );
} else { // If logged in:
    echo 'you are already logged in';
    wp_loginout( home_url() ); // Display "Log Out" link.
    echo " | ";
    wp_register('', ''); // Display "Site Admin" link.
}
?&gt;


And in the functions.php page, I am using the following code to redirect users to the homepage after they log in:

function my_login_redirect( $redirect_to, $request, $user ){
    //is there a user to check?
    if( isset( $user-&gt;roles ) &amp;&amp; is_array( $user-&gt;roles ) ) {
        //check for admins
        if( in_array( "administrator", $user-&gt;roles ) ) {
            // redirect them to the default place
            return $redirect_to;
        } else {
            return home_url();
        }
    }
    else {
        return $redirect_to;
    }
}
add_filter("login_redirect", "my_login_redirect", 10, 3);


My question is:, Is there a way to redirect users to the 'referrer page (page from where they logged in)' after they login by making changes to the above code or perhaps using a better code?

Thanks in advance.


Question: What is happening when I convert from a source color space AdobeRGB to a Canon photo paper profile?
Answer: Short Answer

You should not actually convert your images directly into the printer space, as you then actually lose the ability to properly color manage your results.

For color management to work, each device involved in the process needs to be assigned a color profile. The image should be assigned an appropriate color space itself, and that is usually sRGB, AdobeRGB, or ProPhotoRGB. The color space, when assigned to an image, is the images color profile. The computer screen should be assigned its own separate color profile, usually by using a color profiling tool with a matched software package. Finally, if printing, the printer should also have a color profile, which is selected when printing actually takes place.



Color Spaces

Color spaces define how the colors of an image fit within the available known range of color, officially called L*a*b*, or just Lab for short. The Lab space models the entire range of known color as far as the human eye can perceive it, according to studies done by the IE in the 1930s. Standard color spaces such as sRGB, AdobeRGB, and ProPhotoRGB simply define how each color as it can be described by a computer map to specific color "coordinates" in Lab space. It is best to only assign one of these to your images. Which one you assign does not actually matter for the most part, however the smaller the space you assign, the more difficult it will be to preserve maximum original information (i.e. sRGB is a fairly small gamut vs. ProPhotoRGB, and downconverting my require multiple colors to reference the same colors in the end.)

Screen Profiles

In order to properly observe your photographs with accurate color on a computer screen, you should calibrate it. Screen calibration is usually done with some kind of device, a colorimiter or a spectrophotometer, which measures the color output of your screen and produces a custom ICC profile specifically for it, and the environment within which it resides. 

A custom ICC profile will ensure that your screen is reproducing color as accurately as possible, and your photography should not only look more realistic (which may mean less saturated!), but it should display finer levels of contrast between pixels better, so what you see on screen should be crisper and sharper. Having a calibrated screen is not a necessity, however it is highly recommended, as comparing prints to an oversaturated screen can make you wonder why things don't seem to match up.

Print Profiles

To print accurately, you need a print profile. Note that is "print" profile, not "printer" profile. A print profile actually takes into account the printer, its inks, as well as the paper being printed on. Print is probably the most complex thing to calibrate, as so many potential factors come into play, so it is not generally recommended to create your own print profiles.

Most paper manufacturers offer ICC profiles for all of their papers and a variety of printers. At the very least, the top Epson and Canon printers will have ICC profiles from most paper manufacturers like Hahnemuhle, Illford, Red River, etc. If you do not yet have the necessary print profile, I highly recommend finding them and installing them into your system.



Image Color Management

It should be noted that the print profile calibrates the printer, ink, and paper....NOT the image. The image is calibrated by its color space. For the whole entire color space conversion process to work, Image Color Management, or ICM...a component of most computer systems these days, will handle conversion for you. So long as each component involved is properly calibrated, the image viewed on screen and the image printed should look very similar. There will always be some slight differences due to the nature of print (i.e. printing on a warm paper while your screen is calibrated to a D65 whitepoint will result in a white balance shift between the two.) 

If you assign a profile for a different component to the wrong thing, such as a print profile to an image, not only will the image look wrong on screen, but it will likely look doubly wrong in print. Keep each component assigned its proper profile from the proper pool of valid profiles, and everything should remain consistent.