ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Show content only to admin

April 29, 2008 1:27pm

Subscribe [2]
  • #1 / Apr 29, 2008 1:27pm

    bohara

    42 posts

    I have live site that I am working on, and I need to build out a new section.  I only want to show the content to me the ‘admin’ when I am logged in to the back-end working on it.

    I tried the following:

    {if {username} == ‘admin’}
        DSPLAY CONTENT
    {if:else}
        UNDER CONTRUCTION
    {/if}

    But this does not seem to work.  Any Suggestions?

  • #2 / Apr 29, 2008 1:48pm

    Mark Bowen

    12637 posts

    Try this instead :

    {if member_group == "1"}
    Display content
    {if:else}
    Under construction
    {/if}

    The code above will work for Super Admin accounts which is what I guess you are using? Another easier way would be to use the Template Access Restriction which would allow you to restrict a template to just yourself and no-one else and you can re-direct the user to a different template to show your under construction message or whatever else you wish. Stops you having the need for loads of {if} statements on your pages and when you want to give access back to users then you can just turn off the restrictions.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / Apr 29, 2008 1:56pm

    bohara

    42 posts

    Mark,
    That worked like a charm. Thanks.

  • #4 / Apr 29, 2008 2:08pm

    Mark Bowen

    12637 posts

    No problem. Glad to have been of help 😉

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases