WordPress.org

Ready to get started?Download WordPress

Forums

Disable Author Pages
notice warning. can you pls fix? (6 posts)

  1. BackuPs
    Member
    Posted 5 months ago #

    Hi

    when you enable Redirect non exists author pages a 404 on your website throws a notice warning.

    Notice: Trying to get property of non-object in wp-includes/post-template.php on line 29

    Can you pls correct the code?

    Thnx

    B.

    https://wordpress.org/plugins/disable-author-pages/

  2. BackuPs
    Member
    Posted 5 months ago #

    nope that also did not fix it

  3. BackuPs
    Member
    Posted 5 months ago #

    its caused by

    && author_can( get_the_ID(), 'administrator' )
    

    sorry

  4. BackuPs
    Member
    Posted 5 months ago #

    wrong code

  5. BackuPs
    Member
    Posted 5 months ago #

    Hi

    here is the real fix to this issue dealing with all options and settings and get rid of the notice.

        static public function disable_author_page() {
            $authorrequest = FALSE;
            $request = ( isset( $_SERVER[ 'REQUEST_URI' ] ) ? $_SERVER[ 'REQUEST_URI' ] : $_SERVER[ 'SCRIPT_NAME' ] . ( ( isset( $_SERVER[ 'QUERY_STRING' ] ) ? '?' . $_SERVER[ 'QUERY_STRING' ] : '') ) );
            if ( is_404() && stripos( $request, '/author/' ) == 0 ) {
                if ( get_option( 'disable_author_pages_redirect_non_authors' ) == 1 ) {
                    $authorrequest = TRUE;
                }
            }
    		if ( is_404() && stripos( $request, '/author/' ) === false ) {
    			return;
    		}
    
            if ( ( is_author() || $authorrequest ) && get_option( 'disable_author_pages_activate' ) == 1 ) {
                $adminonly = get_option( 'disable_author_pages_adminonly', '0' );
    			$author_can=false;
    
    			if (!is_404() && $adminonly) {
    					global $post;
    					if( is_object($post)) {
    						$author_can = author_can( get_the_ID(), 'administrator');
    					}
    			}
    
                if ( $adminonly && $author_can===true || !$adminonly && !is_404() || is_404() && ( get_option( 'disable_author_pages_redirect_non_authors' ) == 1 ) ) {
                    $status = get_option( 'disable_author_pages_status', '301' );
                    $url = get_option( 'disable_author_pages_destination', '' );
                    if ( $url == '' ) {
                        $url = home_url();
                    }
                    wp_redirect( $url, $status );
                    exit;
                }
            }
        }
    

    Best regards,

  6. Frank Staude
    Member
    Plugin Author

    Posted 5 months ago #

    Hi BackuPs,

    thanxs for the code.

    i update the plugin now

Reply

You must log in to post.

About this Plugin

About this Topic