• How would I restrict the author archive page to the specific author.
    So, any other author user can’t access the archive page but the author themselves.

    So, author username1 can access the archive page for author username1

    I have been looking for a code snippet for this but I could not find anything

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    There are a number of possible approaches.

    You could customize a template. If your theme doesn’t have an author.php template, create one from its archive.php or index.php template. Custom templates are best kept in a child theme. On the template, somewhere before content you want protected is output, place conditional code that compares the value of get_the_author() against the current user’s nicename (extracted from wp_get_current_user() object).

    If there is not a match, output a message like “You may not view the archive of other authors” from a wp_die() call. Otherwise there’s a match, proceed with the usual template code.

Viewing 1 replies (of 1 total)
  • The topic ‘Restrict Author Archive page to the author’ is closed to new replies.