Hi guys,
I’ve created a custom shortcode for a standard login form to embed on a page. However, it does not display at all unless a user is already logged in. I narrowed it down to an issue with Enfold after changing theme to Twenty Thirteen and finding no hiccups.
Troubleshooting steps are below:
The functions.php code is as follows:
add_shortcode( ‘my_login_form’, ‘my_login_form_shortcode’ );
function my_login_form_shortcode() {
$args = array(
‘redirect’ => admin_url(),
‘form_id’ => ‘loginform’,
‘label_username’ => __( ‘Username’ ),
‘label_password’ => __( ‘Password’ ),
‘label_remember’ => __( ‘Remember Me’ ),
‘label_log_in’ => __( ‘Log In’ ),
‘remember’ => true
);$attr = shortcode_atts( $defaults, $attr );
$attr[‘echo’] = false;
wp_login_form();
}
Any ideas?
Cheers!
I got it working after lots of confusion! I realised that I was using a custom page template when I didn’t really need one. With just a default page template the shortcode works, allowing a login form to appear on any random page despite whether the user is authenticated or not.
This could still be considered a bug seeing as the custom shortcode wouldn’t appear for unauthenticated users on a page with a custom template applied via an Enfold Child Theme, but it’s no longer an issue for me!
Thanks anyway guys. Feel free to close the thread.