GetSimple Support Forum

Full Version: Is there something like is_admin() / is_loged_in()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I like to code a page where i want to enable special things for myself to manipulate data, and of course the public should not have this provileges. I would like getsimpe to check if i am logged in. Is there a way?

It seems like you are never loged in into the normal sites. Just the admin panels if i am right? Maybe there is a plugin for this or some easy way to do that?
why don't you set these pages to "private"? Then non-logged in users don't see them

check the page options ;=)

Cheers, Connie
no i dont want to be the pages to be private i want them to show extra forms for the admin (me) to to change mysql entries and stuff. i am working on a small php application
there are filters and hooks which you could use, check the list at the wiki:

http://get-simple.info/wiki/plugins:hooks_filters

maybe you can find something there ;=)

what I can imagine:

1) create a private page
2) create a template for that page, use the filter or hook there
3) create components
4) add these components to the private page

Cheers, Connie
i said i dont want private pages? you dont get it! (or me?)

whats the diffrence beween a private page and a private page with components on in? if its based on a private page normal users cant see the page and thats NOT what i want!

maybe components on a public page that only show up to admins would be nice but how? it dont even needs to be components. i just want to detect a admin in a public page and include something if a admin is logged in.
i know what you are talking about... sort of the way WordPress includes the 'Edit' link on posts when it detects that it's author is logged in. We do not have a function like that, we should though. It should be easy to do since all you have to do is check for existence of a the GS_ADMIN_USERNAME Cookie.
bugmenot Wrote:whats the diffrence beween a private page and a private page with components on in? if its based on a private page normal users cant see the page and thats NOT what i want!

I am sorry that I bugged you ;=)

well, don't make it private, but do make a template for that page with logic, using template hooks or
components

do as you please ;=)

Cheers, Connie
I think 3.1 has sitewide cookies by default, so you should be able to just read the cookie, or use globals.

Code:
GLOBAL $USR;

if (isset($USR) && $USR == get_cookie('GS_ADMIN_USERNAME')) {
  // do stuff
}

Might not be entirely accurate, I only briefly looked into it, I want a working edit this page plugin.
This works with GS 3.1 (but not with 3.0):
Code:
if (cookie_check()=='1') {
  // ... logged in
}

@ccagle8, shawn_a
Time ago I made a small plugin for this: http://get-simple.info/forum/post/6074/#p6074
It works, but it uses its own cookie (that you have to set, once logged).
I intended to update one of these days it to use cookie_check() ...
Carlos Wrote:This works with GS 3.1 (but not with 3.0):
Code:
if (cookie_check()=='1') {
  // ... logged in
}

@ccagle8, shawn_a
Time ago I made a small plugin for this: http://get-simple.info/forum/post/6074/#p6074
It works, but it uses its own cookie (that you have to set, once logged).
I intended to update one of these days it to use cookie_check() ...

I couldn't figure out how to get it working. I thought it was borked. Ill try again.
Thanks!
shawn_a Wrote:I couldn't figure out how to get it working. I thought it was borked. Ill try again.
Thanks!

You mean the plugin? There are two, the one I made and linked in that post (not in Extend), and another (not by me) in Extend, which I don't remember if worked with GS 2.x but is surely not compatible with 3.x
Carlos Wrote:This works with GS 3.1 (but not with 3.0):
Code:
if (cookie_check()=='1') {
  // ... logged in
}

Won't this return true for any logged in user ? Would my code be better for multi user sites, for checking if user is admin.

EDIT:
hmm i was wrong, you still need to have a default admin account somehow to check against, is there a way to know the default admin account with multi user plugin installed ?