Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6202045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:39:48+00:00 2026-05-24T04:39:48+00:00

I wonder if there is a way using Jquery to detect if a user

  • 0

I wonder if there is a way using Jquery to detect if a user is an administrator and allows them to click a link.
For all on admin users, there is a e.preventDeafult() active on said link.

Is that possible, anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:39:48+00:00Added an answer on May 24, 2026 at 4:39 am

    Since JS is run in the browser, there is no full-proof way to do this (your JS code can always be modified). But here are two solutions. The first is less full-proof than the second, but much simpler & offers a better user experience.

    1. Have your php template echo a hidden div that contains a value (such as true or false) that your jQuery code can access to determine if the user is an administrator.

    2. Have the link actually make an AJAX request. That way, the determination can be done by the PHP in the URL that the request is made to.

    #1 is easier to hack because it provides two places to hack: 1) the DOM value (true or false) and 2) The code in the script itself (in case you didn’t know, this can be modified on the fly by the user).

    #2 only offers the second of these scenarios.

    BUT, it’s obviously more complicated, and since both are hackable and the user is someone trustworthy I assume (since it’s an admin), i’d just go with #1.

    I actually do this kind of thing quite frequently on my Drupal site. Never in a place where it could create a security issue, of course (i.e. if making an AJAX request, I never trust that my JS is sending the right logged in uid to the server; instead, I always use global $user in the PHP code that is processing the request).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if there is a way to either programatically or using a third
jQuery has the very cool feature/method .data, I wonder if there is a way
I wonder whether there is a way using awk to number the lines according
I wonder if there's a way to do the following: I have a structure
I wonder if there is a way to create a Custom List in Sharepoint,
i wonder if there is a way to access a control's templatepart from within
I wonder if there is a way to set the value of #define in
i wonder if there is a way to generate valid GUIDs/UUIDs where the first
I wonder if there is a way to use ungreedy matching in JavaScript? I
i wonder if there is a way to specifiy a custom ServiceHost (i.e. a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.