Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
290 stars 205 forks source link

Can't remove redirect to Guest Author archive page #935

Open photocurio opened 1 year ago

photocurio commented 1 year ago

I need to remove the redirect that sends requests for Author pages to linked Guest Author pages. The redirect is in class-coauthors-guest-authors.php, on line 44:

    // Redirect if the user is mapped to a guest author
    add_action( 'parse_request', array( $this, 'action_parse_request' ) );

I've tried several different ways to remove it, but nothing works.

I've tried adding a remove_action hook in init, like this:

function remove_coauthors_plus_parse_request() {
    global $coauthors_plus;
    remove_action( 'parse_request', array( $coauthors_plus->guest_authors, 'action_parse_request' ) );
}

add_action( 'init', 'remove_coauthors_plus_parse_request' );

I've also tried instantiating the CoAuthors_Guest_Authors class and removing the parse_request action on plugins_loaded like this:

function remove_coauthors_plus_parse_request() {
    $guest_authors_class = class_exists('CoAuthors_Guest_Authors') ? new CoAuthors_Guest_Authors : null;
    remove_action( 'parse_request', array( $guest_authors_class, 'action_parse_request' ) );
}
add_action( 'plugins_loaded', 'remove_coauthors_plus_parse_request' );

Got any tips?

photocurio commented 1 year ago

NM, solved it. It needs priority 12:

add_action( 'init', 'remove_coauthors_plus_parse_request', 12 );

public function remove_coauthors_plus_parse_request() {
    global $coauthors_plus;
    remove_action( 'parse_request', [ $coauthors_plus->guest_authors, 'action_parse_request' ] );
}