PDA

View Full Version : User profile settings - How to add a link to Profile.php


thetechgenius
09-12-2014, 12:14 PM
Right now the links to the profile settings are like this:




http://example.com/profile.php?do=editprofile



I have added a custom Setting Page to Profile.php, using this code in profile.php:



$cmd = $_GET['cmd'];
switch($cmd)
{
case "extrasettings":
@include('profile_extra.php');
break;
}



However, to get to my custom setting page, the link is like this:



http://example.com/profile.php?cmd=extrasettings




My question is, how do I make the link show up as the other Profile Setting Links? How can I make the link show up like this: "?do=extrasettings" instead of "?cmd=extrasettings" . I would like to change the "cmd" to "do" like the other profile links.



Example:


http://example.com/profile.php?do=extrasettings

Dave
09-12-2014, 12:34 PM
Use the profile_start hook and then just do something like:

if($_REQUEST['do'] == "extrasettings")
{
// Your code.
}

Don't forget to attach it to a template though.

thetechgenius
09-12-2014, 04:55 PM
Use the profile_start hook and then just do something like:

if($_REQUEST['do'] == "extrasettings")
{
// Your code.
}

Don't forget to attach it to a template though.


Thank you for helping me. But where would I add that code? Should I make a new plugin? Or should I just add the code to Profile.php?

Lynne
09-12-2014, 05:07 PM
As Dave said, you would use a plugin and use the profile_start hook for the plugin.

thetechgenius
09-12-2014, 05:23 PM
As Dave said, you would use a plugin and use the profile_start hook for the plugin.

I tried this code with the hook "profile_start" , and when I go to "mysite.com/profile.php?do=extrasettings" , it just comes up with a white/blank page. I have no idea what I am doing wrong.

Plugin Code:


if($_REQUEST['do'] == "extrasettings")
{
@include('profile_extra.php');

}



I have even tried using the hook "profile_editoptions_start", but it was the same thing, blank white page.

EDIT: Im sorry, when I use the hook "profile_start", I get a "500 - Internal Server Error", when I use the hook "profile_editoptions_start", I get the blank/white page.


I can access the custom setting's page fine with "mysite.com/profile.php?cmd=extrasettings". I just cant get it to work like this: "mysite.com/profile.php?do=extrasettings"

tbworld
09-12-2014, 06:23 PM
We need to see the "extrasettings" code in order to assist. If you are using a proper editor and have not created a BOM, then the problem rests in your included code, not the hook location. The hook as you probably already know selects the point of entry where your code will be eval'ed. :)

If for some (security reason -- only) you cannot post your code to receive global assistance you can use a private message.

What @Dave suggested is the correct method and there is nothing wrong with the hook locations. :)

thetechgenius
09-12-2014, 07:34 PM
We need to see the "extrasettings" code in order to assist. If you are using a proper editor and have not created a BOM, then the problem rests in your included code, not the hook location. The hook as you probably already know selects the point of entry where your code will be eval'ed. :)

If for some (security reason -- only) you cannot post your code to receive global assistance you can use a private message.

What @Dave suggested is the correct method and there is nothing wrong with the hook locations. :)

Ok, I finally got it working correctly. I actually copy and pasted my custom setting page code into Profile.php.

There is one more problem though, after I edit my profile setting and go to "Save", it saves the changes, but it redirects to "profile.php?do=editoptions" and not back to the previous page "profile.php?do=extrasettings"


Should I copy and paste my entire profile.php code?

Edit: I fixed it. I found out that the function "updateoptions" was being used twice, so the code I added, was using the first "updateoptions" function and redirecting the extra settings page to the EditOptions page on Submit. I simply just had to use a different function, such as "do=updatesettings", and of course add the redirect code " exec_header_redirect('profile.php?do=extrasettings '); " . All seems to be working correctly now. Thank you all for helping me out, I really do appreciate it.

tbworld
09-12-2014, 08:41 PM
Just paste your addon code and let us know where you pasted it the profile.php.

Either method is fine:
------------------------
1. Provide us with a unique search string where you placed your code.
2. If profile.php was previously unmodified, then provide us with the vbulletin version you are using and a line number where you placed the code.

If it is off a few lines, don't worry, we will figure it out.
:)