• Hi!

    We currently have different author templates setup like author-this.php for users with the “this” role and author-that.php for authors with that “that” role etc.

    I need to setup a conditional in our header to display different things based on those different authors/templates.

    I could be wrong but using the is_archive seems to blanket all of them regardless of what I try to add with it.

    is_author doesn’t seem to address user roles.

    So I can’t seem to find a way to combine a conditional or anything to control them separately. Any ideas? Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter johnsimoneau

    (@johnsimoneau)

    Thanks for the quick response!

    In this case I’m actually changing meta tags that I need everyone to see. Won’t the current_user_can function only display that info to the current user instead of everyone else?

    Can you kindly make it a bit clear.

    Thread Starter johnsimoneau

    (@johnsimoneau)

    This isn’t exactly the scenario because I think the exact scenario is harder to explain but if I can figure this out it will apply fine for what i need to do. So if this example is weird ignore the weirdness of it…

    Users with the “this” role have custom profile fields labeled something like seo_title and seo_description. These fields are called in the header by:

    <?php
    if( isset( $_GET['author_name'] ) ) {
        $profile_user = get_userdatabylogin($author_name);
    } else {
        $profile_user = get_userdata(intval($author));
    }
    ?>
    <title><?php echo $profile_user->seo_title; ?></title>
    <meta name="description" content="<?php echo $profile_user->seo_description; ?>" />

    They were applied to the correct user profile template by using:

    is_archive( 'this' ))

    But now we’ve added user role ‘that’ with different custom profile fields like seo_title_two and seo_description_two. We need to call those via the same fashion above but applied to the ‘that’ template.

    I’ve tried adding is_archive( 'that' ))

    below the other one but it doesn’t work. One is_archive seems to control both instead of them working independently. Hopefully that makes some kind of sense…

    Thanks!

    Thread Starter johnsimoneau

    (@johnsimoneau)

    So I need users with the role “this” or author-this.php template to display seo_title and seo_description meta tags in the header.

    Then I need users with the role ‘that’ or author-that.php template to display seo_title_two and seo_description_two meta tags in the header.

    <?php } else if ( is_archive( 'this' )) {  ?>
    meta tags
    
    <?php } else if ( is_archive( 'that' )) {  ?>
    different meta tags

    isn’t working. They just show ‘this’ for both users or vica versa.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Conditional based on author template or role’ is closed to new replies.