vForums Support > Programming & Coding :: Code Requests & Support :: > Modify Profile ReLinking

Modify Profile ReLinking - Posted By dog199200 (dog199200) on 10th Sep 09 at 3:02am
I need a code that will allow me to change where the Modify profile button is linked to unless the user is an administrator. The reason for this is because i'm using the api and have it so the information is updated off the forum so I can keep information in all the databases up to date at the same time.

Re: Modify Profile ReLinking - Posted By Dreg[Bot] (dregondrahl) on 10th Sep 09 at 4:48pm
Code:
 
  1. <script type="text/javascript">
  2. <!--
  3.  
  4. var vf_admin = false;
  5.  
  6. for (var i = 0; i < vf_usergroup.length; i ++)
  7. {
  8.     if(vf_usergroup[i] == '1')
  9.     {
  10.         vf_admin = true;
  11.     }
  12. }
  13.  
  14. if ( ! vf_admin && get('profile_links', ID))
  15. {
  16.     var pro_link = get('profile_links', ID).getElementsByTagName('a')[0];
  17.         
  18.     if (pro_link.href.match(/modify_profile/i))
  19.     {
  20.         pro_link.href = 'http://google.com';
  21.     }
  22. }
  23.  
  24. //-->
  25. </script>
  26.  
  27.  
 



Re: Modify Profile ReLinking - Posted By dog199200 (dog199200) on 10th Sep 09 at 5:25pm
it does the redirect perfectly fine, but it doesn't check to see if the user is an admin in order to remove the redirect.

Re: Modify Profile ReLinking - Posted By Dreg[Bot] (dregondrahl) on 10th Sep 09 at 8:03pm
it checks if your admin and group: 1, check your group value in the source code and change as needed.

Re: Modify Profile ReLinking - Posted By dog199200 (dog199200) on 10th Sep 09 at 10:04pm
i'm still clueless the admin group is 1, "var vf_usergroup = Array('1', '4');" 1 = Admin, 4 = Paid Member. I'm not sure why I can't get the group check to work at all.... I might have to add all the admins in manually by their username, which would just be redundant over time.

Re: Modify Profile ReLinking - Posted By Dreg[Bot] (dregondrahl) on 11th Sep 09 at 1:35am
Fixed bug, try now =]

Re: Modify Profile ReLinking - Posted By dog199200 (dog199200) on 11th Sep 09 at 2:21am
all good, thank you.

Re: Modify Profile ReLinking - Posted By Dreg[Bot] (dregondrahl) on 11th Sep 09 at 8:00am
{Cool}