vForums Support > Programming & Coding :: Code Requests & Support :: > Provent A Profile From Being Edited

Provent A Profile From Being Edited - Posted By dog199200 (dog199200) on 13th Oct 08 at 2:52am
OK I need a code taht will prevent an users profile from being edited, not even by them. I am requesting this because I have a guest accoutn setup on my forum so people can see the API system on the website, and i need to make sure people can not edit the guest profile on the forum and add in bad things and stuff. I would try to cod ethis myself, but I ain't got a clue where to start.

Re: Provent A Profile From Being Edited - Posted By Ross (admin) on 16th Oct 08 at 9:53am
So just prevent this profile from being edited? (rather than all profiles)

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3.  
  4.     if(document.profile_form && document.profile_form.user && document.profile_form.user.value == "test-account-id") {
  5.         var input = get('input', TAG);
  6.         for(i = 0; i<input.length; i ++) {
  7.             input.item(i).disabled  = true;
  8.         }
  9.     } else if(location.href.match(/\/view_profile/)) {
  10.         var a = get('a', TAG);
  11.         for(i = 0; i<a.length; i ++) {
  12.             if(a.item(i).href.match(/modify_profile\/user\/test-account-id(\/|$)/)) {
  13.                 a.item(i).style.display = 'none';
  14.                 a.item(i).parentNode.removeChild(a.item(i).nextSibling);
  15.                 break;
  16.             }
  17.         }
  18.     }
  19.  
  20. -->
  21. </script>
 


Replace both instances of "test-account-id" with the username.

Re: Provent A Profile From Being Edited - Posted By dog199200 (dog199200) on 16th Oct 08 at 3:28pm
ok i see how you did it, ok ty


edit: one small thing i didn't account for, can i possible get it so that only the admin account can edit the guest account and no one else can? I forgot that i still need to be able to edit it {Smile}

Re: Provent A Profile From Being Edited - Posted By Ross (admin) on 16th Oct 08 at 11:24pm
Posted By dog199200 on 16th Oct 08 at 3:28pm
 
ok i see how you did it, ok ty


edit: one small thing i didn't account for, can i possible get it so that only the admin account can edit the guest account and no one else can? I forgot that i still need to be able to edit it {Smile}


The simplest way for you to do that would be to wrap it in an if statement which checks the value of vf_username. eg:

<script type="text/javascript">
<!--

// Check that it is not being loaded by "admin"
if(vf_username != "admin") {

     // ... Code to disable form & remove link here ...

}

//-->
</script>

Re: Provent A Profile From Being Edited - Posted By dog199200 (dog199200) on 16th Oct 08 at 11:36pm
ah ok so that would work, i didn't think it would so i didn't try..

man i forgot about guests having other features..

I tried to do duplicate this part of the code i order to remove all other profile options, but it wasn't working to well, in fact it was breaking the code:

Code:
 
  1. if(a.item(i).href.match(/modify_profile\/user\/guest1(\/|$)/)) {
  2. a.item(i).style.display = 'none';
  3. a.item(i).parentNode.removeChild(a.item(i).nextSibling);
  4. break;
 


Where it says "modify_profile" i tried putting in the other links names like "view_buddies" or "notifications"

Sorry I am still learning, I hope soon that I won't have to ask for help anymore.

Re: Provent A Profile From Being Edited - Posted By Aiken (ionfortuna) on 30th Dec 09 at 6:19am
View Source might help you with that

Re: Provent A Profile From Being Edited - Posted By Graham (amusedtodeath) on 30th Dec 09 at 9:51am
 
View Source might help you with that


No need to bump threads that are a year old. Thanks {Smile}