Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Kento

    (@proaktion)

    Hi,

    If you don’t get the form, you’re probably logged in already or you had caching enabled when you visited your test page and visited it first while you were logged in. Try to log out and empty the cache please, also you can add the [groups_logout] shortcode.

    References:
    https://docs.itthinx.com/document/groups/shortcodes/groups_login/
    https://docs.itthinx.com/document/groups/shortcodes/groups_logout/

    Cheers

    Thread Starter asha23

    (@asha23)

    Hi,

    I’m afraid it’s neither of those things. I am using the groups_logout shortcode. Still nothing.

    Can you explain what I should see when using the groups_login shortcode? I have looked at your shortcode plugin code (class-groups-shortcode.php) and can’t see the hook to render a login form.

    It appears to render a url? Is this correct?

    Thread Starter asha23

    (@asha23)

    Looking at this line of code in class-groups-shortcode.php

    $output .= wp_login_form(
     array(
      'echo'     => false,
      'redirect' => $redirect
     )
    );

    This doesn’t render the form, unless you set the echo to true.

    Thread Starter asha23

    (@asha23)

    This, however does work. Rather confused – Not keen to change plugin code. But I really needed this functionality to work correctly

    public static function groups_login( $atts, $content = null ) {
    	$current_url = ( is_ssl() ? 'https://' : 'https://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    	extract(
    		shortcode_atts(
    			array(
    				'redirect'        => $current_url,
    				'show_logout'     => 'no'
    			),
    			$atts
    		)
    	);
    
    	$redirect    = trim( $redirect );
    
    	$show_logout = trim( strtolower( $show_logout ) );
    	$output      = '';
    
    	if ( !is_user_logged_in() ) {
    
    		$output .= wp_login_form(
    			array(
    				'echo'     => true,
    				'redirect' => $redirect
    			)
    		);
    	} else {
    		if ( $show_logout == 'yes' ) {
    
    			$output .= self::groups_logout(
    				array(
    					'redirect' => $redirect
    				)
    			);
    		}
    	}
    	echo $output;
    	// return $output;
    }
    Thread Starter asha23

    (@asha23)

    This is not resolved.

    Plugin Author Kento

    (@proaktion)

    There is no need to modify the code and the shortcode works correctly. If you are using the function directly then you must echo its return value.

    Plugin Author Kento

    (@proaktion)

    Plugin Author Kento

    (@proaktion)

    I assume this has helped you and will mark this thread as resolved. If you need further help, please let me know.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[groups_login] Shortcode doesn't render a form’ is closed to new replies.