Home / Admin / Show login form for logged out users
Duplicate Snippet

Embed Snippet on Your Site

Show login form for logged out users

Shows the [edd_login] form on restricted content for logged out users.

Code Preview
php
<?php
function jp_cr_login_form( $content ) {
	if ( ! function_exists( 'edd_cr_is_restricted' ) ) {
		return $content;
	}
	global $post;
	if ( ! is_object( $post ) ) {
		return $content;
	}
	if ( edd_cr_is_restricted( $post->ID ) && ! is_user_logged_in() ) {
		$content .= do_shortcode( '[edd_login]' );
	}
	return $content;
}
add_filter( 'the_content', 'jp_cr_login_form', 11 );

Comments

Add a Comment