Skip to content

Instantly share code, notes, and snippets.

@Cais
Last active May 29, 2019 14:38
Show Gist options
  • Save Cais/5522696 to your computer and use it in GitHub Desktop.
Save Cais/5522696 to your computer and use it in GitHub Desktop.
WPFA Login Form
<?php
/**
* WPFA Login Form
* Borrowed from the core login form and used with the shortcode 'bns_login'
* This allows for the 'bns_login' shortcode to accept all of the parameters
* of the `wp_login_form` function as the shortcode attributes.
*
* @package WPFA_Login_Form
* @since 1.0
*
* @param $args
*
* @internal $defaults copied from codex '$args' entry
* @link http://codex.wordpress.org/Function_Reference/wp_login_form
*
* @uses __
* @uses shortcode_atts
* @uses site_url
* @uses wp_login_form
* @uses wp_parse_args
*
* @return string - the login form
*/
function wpfa_login_form( $args ) {
$defaults = shortcode_atts( array(
'echo' => false,
'redirect' => site_url( '/wp-admin/' ),
'form_id' => 'loginform',
'label_username' => __( 'Username', 'wpfa-textdomain' ),
'label_password' => __( 'Password', 'wpfa-textdomain' ),
'label_remember' => __( 'Remember Me', 'wpfa-textdomain' ),
'label_log_in' => __( 'Log In', 'wpfa-textdomain' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => true,
'value_username' => NULL,
'value_remember' => false
), $args );
$login_args = wp_parse_args( $args, $defaults );
return wp_login_form( $login_args );
} /** End function - WPFA login form */
add_shortcode( 'wpfa_login', 'wpfa_login_form' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment