Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter rp07

    (@rp07)

    `<?php
    add_action( ‘template_redirect’, ‘ps_shop_redirect’ );
    function ps_shop_redirect() {
    if ( !is_user_logged_in() && is_page( ‘shop’ ) || is_page( ‘kundenkonto’)) {
    wp_redirect( ‘member-login’ );
    exit;
    }
    }

    add_action( ‘template_redirect’, ‘ps2_shop_redirect’ );
    function ps2_shop_redirect() {
    if ( is_user_logged_in() && is_page( ‘member-login’ )) {
    wp_redirect( ‘account’ );
    exit;
    }
    }

    add_action( ‘template_redirect’, ‘ps3_shop_redirect’ );
    function ps3_shop_redirect() {
    if ( !is_user_logged_in() && is_page( ‘wp-admin’ )) {
    wp_redirect( ‘member-login’ );
    exit;
    }
    }
    ?>
    <?php
    add_shortcode( ‘login_logout’, ‘login_logout’ );
    /**
    * Add a login/logout shortcode button
    * @since 1.0.0
    */
    function login_logout() {
    ob_start();
    if (is_user_logged_in()) :
    // Set the logout URL – below it is set to the root URL
    ?>
    <a href=”<?php echo wp_logout_url(‘/’); ?>” style=”text-align: right;”><i class=”fas fa-sign-out-alt”></i></a><br>
    <a href=”<?php echo (‘/account’); ?>” style=”text-align: right;”><i class=”far fa-user”></i> </a>

    <?php
    else :
    // Set the login URL – below it is set to get_permalink() – you can set that to whatever URL eg ‘/whatever’
    ?>
    <a href=”<?php echo (‘/member-login’); ?>” style=”text-align: right;”><i class=”fas fa-sign-in-alt”></i></a>

    <?php
    endif;

    return ob_get_clean();
    }

    add_filter(‘woocommerce_login_redirect’, ‘custom_login_redirect’);
    function custom_login_redirect( $redirect, $user ) {
    $redirect = site_url( ‘/account’ );
    return $redirect;
    }

    add_action( ‘wp_login_failed’, ‘stro_login_fail’ ); // hook failed login
    function stro_login_fail( $username ) {
    $referrer = $_SERVER[‘HTTP_REFERER’]; // where did the post submission come from?
    // if there’s a valid referrer, and it’s not the default log-in screen
    if ( !empty($referrer) && !strstr($referrer,’wp-login’) && !strstr($referrer,’wp-admin’) ) {
    wp_redirect(‘member-login’ . ‘/?login=failed’ ); // let’s append some information (login=failed) to the URL for the theme to use
    exit;
    }
    }

    add_action( ‘authenticate’, ‘check_username_password’, 1, 3);
    function check_username_password( $login, $username, $password ) {

    // Getting URL of the login page
    $referrer = $_SERVER[‘HTTP_REFERER’];

    // if there’s a valid referrer, and it’s not the default log-in screen
    if( !empty( $referrer ) && !strstr( $referrer,’wp-login’ ) && !strstr( $referrer,’wp-admin’ ) ) {
    if( $username == “” || $password == “” ){
    wp_redirect( ‘member-login’ . “?login=empty” );
    exit;
    }
    }

    }

Viewing 1 replies (of 1 total)