Coder Social home page Coder Social logo

Comments (4)

lumpysimon avatar lumpysimon commented on June 10, 2024

It's impossible to say without seeing your code. Can you paste your code up on somewhere like https://gist.github.com/ or http://pastebin.com/ (or fork this repo and commit your changes) and let me know the URL here and I'll take a look.

from wp-force-password-change.

jibranb avatar jibranb commented on June 10, 2024

Thanks for your response. I figured out a solution. Here are the changes I made to the redirect() function.

  • added an else section to handle an "allowed" front-end URL
  • updated wp_redirect() to use the WooCommerce Edit Account URL
function redirect() {

    global $current_user;

    if ( is_admin() ) {
        $screen = get_current_screen();
        if ( 'profile' == $screen->base )
            return;
        if ( 'plugins' == $screen->base )
            return;
    } else {
        global $wp;
        $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
        if ( strpos( $current_url, 'edit-account' ) ) {
            return;
        }
    }

    if ( ! is_user_logged_in() )
        return;

    wp_get_current_user();

    if ( get_user_meta( $current_user->ID, 'force-password-change', true ) ) {
        wp_redirect( get_site_url() . '/my-account/edit-account' );
        exit; // never forget this after wp_redirect!
    }

}

Thanks,
-J

from wp-force-password-change.

lumpysimon avatar lumpysimon commented on June 10, 2024

Great, glad you figured it out!

from wp-force-password-change.

LachlanArthur avatar LachlanArthur commented on June 10, 2024

This can be fixed for almost all front-end profile plugins (WooCommerce, TML, etc) by simply checking if the current page is the same as the redirect.

Add this before if ( ! is_user_logged_in() ):

if ( wp_make_link_relative( admin_url( 'profile.php' ) ) == $_SERVER['REQUEST_URI'] )
    return;

A nice addition would be a filter to allow custom overrides to be added without modifying the plugin.

from wp-force-password-change.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.