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

  • SEARCH
  • Home
  • 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 6996543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:10:14+00:00 2026-05-27T20:10:14+00:00

In adding some js grids to an existing PHP application I ran into the

  • 0

In adding some js grids to an existing PHP application I ran into the following…

In one section of the site I need to display different content to different user roles. I can check for their role with a simple pre-built method n the PHP app, however I need to tell the JS side of things what the role is so it can display the correct content.

My first thought was to write the role to the dom in a hidden div and then retrieve it for use in JS:

<?php echo '<div id="user_role" style="display:none">5</div>'; ?>

then…

var user_role = $('#user_role').text();

But obviously this is not a good idea as anyone with access could manipulate the value in the dom and set it to whatever they like. So my question…

What’s the best way to set a user’s role for use with javascript in this sort of situation?

  • 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-27T20:10:15+00:00Added an answer on May 27, 2026 at 8:10 pm

    The real answer here is anything on the client side in javascript a user can manipulate, so your best only showing your content specific to users on the server side with your php.

    Also if you where to go down the route you where showing above you dont need to go through all that code you could simply use the code below no need to go round the houses adding it to the dom.

    var user_role <?php echo(5); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am overriding a Grid, adding some customer features. One of the features is
I'm adding some functionality to my site so that users can upload their own
I'm thinking about adding some kind of copy protection to one of my tools.
I'm looking into adding some unit tests for some classes in my data access
I'm adding some ASP.NET MVC pages to an existing ASP.NET Web Forms project. I've
I am adding some user controls dynamically to a PlaceHolder server control. My user
I'm currently adding some new extended classes to this code: foreach (BaseType b in
I was thinking of adding some Achievements to our internal bug-tracking and time logging
I'm adding some lazy initialization logic to a const method, which makes the method
Looking at adding some data graphing to a new iPhone app in development (ala

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.