Adsense

Login form shortcode for WordPress

Here we learn how to displaying login forms on wordpress using a shortcode Paste the following code into functions.php file:

function sandip_login_form_shortcode() {
    if ( is_user_logged_in() )
        return '';

    return wp_login_form( array( 'echo' => false ) );
}

function sandip_add_shortcodes() {
    add_shortcode( 'sandip-login-form', 'sandip_login_form_shortcode' );
}

add_action( 'init', 'sandip_add_shortcodes' );

Once done, we can now use the shortcode as shown in the following example. just paste it on the post editor, where you want the login form to be displayed. [sandip-login-form]
 
Reference site http://php-mysql-guide.blogspot.com/

newest questions on wordpress