vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   User profile settings - How to add a link to Profile.php (https://vborg.vbsupport.ru/showthread.php?t=314263)

thetechgenius 09-12-2014 12:14 PM

User profile settings - How to add a link to Profile.php
 
Right now the links to the profile settings are like this:


Code:


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

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

Code:


$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:

Code:


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:
Code:


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:

PHP Code:

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


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

thetechgenius 09-12-2014 04:55 PM

Quote:

Originally Posted by Dave (Post 2514840)
Use the profile_start hook and then just do something like:

PHP Code:

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

Quote:

Originally Posted by Lynne (Post 2514883)
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:
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

Quote:

Originally Posted by tbworld (Post 2514891)
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.
:)


All times are GMT. The time now is 01:19 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01031 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete