• Resolved Stephen

    (@idiots_guide)


    I can make the do_shortcode works in template, codes are copied from clean_login_load_before_headers();. My post do not content any shortcode. Is there any better way, more simpler than this?

    $url = clean_login_url_cleaner( wp_get_referer() );
    // LOGIN
    if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'login' ) {
    	$url = get_option( 'cl_login_url', '');
    	$user = wp_signon();
    	if ( is_wp_error( $user ) )
    		$url = esc_url( add_query_arg( 'authentication', 'failed', $url ) );
    	else {
    		// if the user is disabled
    		if( empty($user->roles) ) {
    			wp_logout();
    			$url = esc_url( add_query_arg( 'authentication', 'disabled', $url ) );
    		}
    		else
    			$url = get_option('cl_login_redirect', false) ? esc_url(get_option('cl_login_redirect_url')): esc_url( add_query_arg( 'authentication', 'success', $url ) );
    	}
    	wp_safe_redirect( $url );
    }
    
    get_header();
    
    if( !is_user_logged_in() ){
    	echo do_shortcode('[clean-login]');
    }

    https://ww.wp.xz.cn/plugins/clean-login/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Alberto Hornero

    (@hornero)

    IMHO, that’s the easiest way! Thanks for sharing with the community 🙂

    Alberto.

    Thread Starter Stephen

    (@idiots_guide)

    OK Thank you.

    Maybe this only useful for people who are not interested to using shortcode in their posts.

    So the do_shortcode need a helper to get the default value of login_url, edit_url, register_url and restore_url.

    I made a little addition to the clean-login.php.

    After first appearance of $logoutredirect_url, add:

    $login_url_man = get_option( 'cl_login_url_man' );
    $edit_url_man = get_option( 'cl_edit_url_man' );
    $register_url_man = get_option( 'cl_register_url_man' );
    $restore_url_man = get_option( 'cl_restore_url_man' );

    inside
    if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == $hidden_field_value ) {

    add:

    update_option( 'cl_login_url_man', isset( $_POST['login_url_man'] ) ? get_permalink($_POST['login_url_man']) : '' );
    update_option( 'cl_edit_url_man', isset( $_POST['edit_url_man'] ) ? get_permalink($_POST['edit_url_man']) : '' );
    update_option( 'cl_register_url_man', isset( $_POST['register_url_man'] ) ? get_permalink($_POST['register_url_man']) : '' );
    update_option( 'cl_restore_url_man', isset( $_POST['restore_url_man'] ) ? get_permalink($_POST['restore_url_man']) : '' );

    Then inside form name="form1", for each variable above, add:

    <label style="display:block;" for="login_url_man">Login Form URL (cl_login_url_man)</label>
    	<?php
    	$postid_url = url_to_postid( $login_url_man );
    	wp_dropdown_pages(array(
    		'id'=>'login_url_man',
    		'name'=>'login_url_man',
    		'selected'=>$postid_url,
    		'show_option_none'=>'Select Login Form URL'
    	));
    	?>
    <p> </p>

    and so on. for the rest.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘do_shortcode’ is closed to new replies.