Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Custom page per user

Asked Modified Viewed 2,372 times
A
Ash
A
Ash 10
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

I am trying to set up my fusion site so that when a registered user logs in it re-directs them to a page with content that is viewable only by them.

My thought is to determine which account has access to that individual page (by user account) so that their parents will have access to that same page. I have spent a fair amount of time searching for this and have been unable to locate a process for this.

Keeping in mind that I am not an extremely advanced user of fusion (still love it though) is this a possibility with some simple method?
0 replies

6 posts

J
JoiNNN
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
answered
Veteran Member

All you need to do is check $userdata['user_id']
if ($userdata['user_id'] == 123) { //display content for that user here }

Where 123 is the ID of the user ofc.
0 replies
A
Ash
A
Ash 10
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

Just to make sure I have it right in my head this above line {such a simple one} would get added into the standard custom page.

Where would the option for them to access this page be displayed at without it being visible to all other users?
0 replies
J
JoiNNN
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
answered
Veteran Member

Sorry but I just can't believe you asked that. How hard can it be to comprehend that line of code? Please, just try and learn some basic PHP before getting into creating sites.

if ($userdata['user_id'] == 123) { // <--- there, that decides who sees the content below, in this case the user with user ID 123
    echo "This content can be seen only by the user with user ID 123!";
} elseif ($userdata['user_id'] == 1) { // <--- in this case the user with user ID 1
    echo "This content can be seen only by the user with user ID 1!";
} else {
    echo "This content can be seen by any user, being a member or guest! You could replace this with 'Sorry you have no access to this page' or whatever.";
}


And yes, it can go in a custom page.
0 replies
A
Ash
A
Ash 10
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

Quote

Sorry but I just can't believe you asked that. How hard can it be to comprehend that line of code? Please, just try and learn some basic PHP before getting into creating sites.


Comprehending that line of code was a breeze. As a matter of fact I had already expanded it out to a snippet very similar to the expanded one you posted. I certainly hope this is just you not understanding exactly what I am trying to figure out is the output.

When adding that code to a custom page it works exactly as intended. What I am not sure of is how to take that link generated by the creation of a custom page and make it visible somewhere for just the member it is intended for.

I even tried adding it to a panel to eliminate that but (and this one I don't know) when trying to get a different output for every USER ID it gives one output as intended and one with the permission error output. So feel free to educate me on what a simple concept it is that I am just not aware of...

Merged on Nov 09 2014 at 03:24:32:
Disregard...I got it
Edited by Ash on 09-11-2014 04:25,
0 replies
R
Rimelek
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums
answered
Senior Member

Hi Ash,

I have been trying to understand your question. I am not sure I managed it.

You mentioned parents who have access to the page of their children. Is this your aim?

If I understand well, you want to achieve it using the custom page on administration area and redirect each user to the created page after authentication.

You probably could redirect users to a custom page, but what do you want to show them their? I think we should know more about your aim.

Yes, you can check each userid and write some individual output manually. I do not think it is what you want to do.

In addition, you want to give access to the page for their parents, so you need to know who their parents are.
Do you have an infusion for this or any plan how you would like to solve it or this is also a part of your question?

Well, if I wanted to show some information for a user and their parents, I would try something like this:

//determine userid by url
$show_my_data = empty($_GET['user_id']);
$userid = intval($show_my_data ? $userdata['user_id'] : $_GET['user_id']);

//get the information to show
$info = dbarray(dbquery("select * from table_for_individual_data where user_id = ".$userid);


$access = true;
if (!$show_my_data) {
    //get the IDs of parents
    $parentids = $info['parentids'] ? explode(',', $info['parentids']) : array();
    if (!in_array($userdata['user_id'], $parentids)) {
       //user want to see data of a user, but the user is not a parent
       $access = false;
    }

}

if ($access) {
    //show data of user using variable $info
} else {
    //show an error message
}


Note that it is just an example and I do not know exactly what you want to do.

When you create a custom page the link of the page will be displayed for you. For example: "viewpage.php?page_id=1"

With this link users can see their own page. You can append "&user_id=157" to show the page of user whom id is 157.

So the link will be this: "viewpage.php?page_id&user_id=157"

Quote

Of course we can not cover everything, but a lot.
- by Richard Ainz


Yes. If I understand well what Ash wants to do, it can not be done simply with tools of PHP Fusion.
0 replies
J
JoiNNN
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
answered
Veteran Member



Glad you figured it out Ash.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 6 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

J
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
R
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums
A
A
Ash 10
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet