rankmath display the real admin username in code

#673418
  • Resolved Anonymous
    Rank Math free

    Hi, how can we prevent the real admin username to be displayed by rankmath in this line?

    To mention that in WP User the public display name is set to be different.

    This can be a security issue because someone can identify the real admin username and to target some script to get access to websites with rankmath installed

    .....
    script type="application/ld+json" class="rank-math-schema">{ ....... {"@type":"Person","@id":"https://www......./author/REAL-USERNAME/","name":"admin","description":"admin","url":"https://www......./author/REAL-USERNAME/","image":{"@type":"ImageObject","@id":"..........
    "dateModified":"2023-11-08T16:52:33+02:00","author":{"@id":"https://www......../author/REAL-USERNAME/","name":"admin"},

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    We apologize for the inconvenience you are facing. To prevent the real admin username from being displayed in the Rank Math Schema, you can use the following filter in your theme’s functions.php file:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if ( ! isset( $data['Person'] ) ) {
            return $data;
        }
        if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
            $data['Person']['name'] = get_the_author_meta( 'display_name', $data['Person']['@id'] );
        }
        return $data;
    }, 99, 2);

    This filter will replace the real admin username with the public display name set in the WP User. This will help prevent any security issues related to the real admin username being exposed in the Schema markup.

    If you have any further questions or need additional assistance, please feel free to contact our dedicated support team. We are available 24/7, 365 days a year.

    Sources:
    How to Change Your Username in Rank Math » Rank Math
    How Does the Author Schema Entity Work? » Rank Math
    How to View the Unminified Version of Rank Math Schema » Rank Math
    How to Make Your Theme Rank Math Compatible » Rank Math

    Anonymous
    Rank Math free

    bot solution has not fixed the issue

    Hello,

    Apologies for the inconvenience.

    The Author URL is taken from the WordPress profile URL.

    Please note that the slug of the author URL is created based on the username, and WordPress doesn’t allow changing the author slug by default.

    However, to change the author slug, please use the following plugin:
    https://wordpress.org/plugins/edit-author-slug/

    Hope that helps.

    Anonymous
    Rank Math free

    Thank you,
    Edit Author Slug plugin fixed this issue

    Hello,
    
    You’re welcome.

    We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.
    
    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
    
    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
    
    Thank you.

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

The ticket ‘rankmath display the real admin username in code’ is closed to new replies.