How To Add A WordPress Login Form Using Widgets (Shortcode)

WordPress login form widget

Login To WordPress With Your Email AddressA WordPress user login form is a great way to provide fast access to your WordPress blog or website for administrators to subscribers. Unfortunately, WordPress does not provide a standard WordPress login widget, which we think should be included in all WordPress systems.

  • In this article/tutorial, we are not going to make a widget, but a shortcode for a login form which can be inserted into widgets through text.
A shortcode in widgets?

WordPress does not automatically allow shortcodes in widgets without the use of the do_shortcode function. So, we have taken this do_shortcode function and  a wp_login_form function from DevPress, which together allows you to place a WordPress login form shortcode in a widget slot… or allows you to use any other shortcode in widgets. (Also see: Using shortcodes in template files)

  • Learn more about styling the WordPress login form.
  • Down 1. Copy and paste the code below into your functions.php file

    add_filter('widget_text', 'do_shortcode');
    function devpress_login_form_shortcode() {
    if ( is_user_logged_in() )
    return '';
    return wp_login_form( array( 'echo' => false ) );
    function devpress_add_shortcodes() {
    add_shortcode( 'devpress-login-form', 'devpress_login_form_shortcode' );
    add_action( 'init', 'devpress_add_shortcodes' );

    WordPress Login Form Widget ShortcodeUse Shortcode 2. Use shortcode:
    inside text in any widget slot.

    Sean Doyle

    Sean Doyle is a tech author and engineer with over 20 years of experience in cybersecurity, privacy, malware, Google Analytics, online marketing, and other topics. Sean's content has been featured in numerous publications.

    Leave a Reply

    Your email address will not be published.

    This site uses Akismet to reduce spam. Learn how your comment data is processed.