IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49

» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21

» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28

» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15

» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11

» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24

» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58

» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50

» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22

» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12

» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10

» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51

» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11

» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19

» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34

Recent Tutorials
Top posting users this month

Who is online?
In total there are 12 users online :: 0 Registered, 0 Hidden and 12 Guests

None

[ View the whole list ]


Most users ever online was 515 on Tue 14 Sep 2021, 15:24

Search found 1 match for field_id3

Ange Tuteur
Sun 08 May 2016, 11:55

Search in: Questions Archive
Topic: [SOLVED] Using ajax to modify user profile
Replies: 3
Views: 1032
@Andrei34 here's a method I wrote awhile back for updating the profile fields via AJAX. It's actually a modified version of how they're already updated when editing fields via your profile.

Install this script in all the pages :
Code:
$.getScript('http://illiweb.com/rs3/25/frm/jquery/json/jquery.json-1.3.min.js', function() {
  window.$updateField = function(o, callback) {
    var c = new Array(),
        admin = $('a[href^="/admin/index.forum"]')[0],
        logout = document.getElementById('logout');

    c.push(new Array(o.name, o.value));
   
    $.post('/ajax_profile.forum?jsoncallback=?', {
          id : o.id.substring(8, o.id.length),
        user : o.user_id,
      active : '1',
      content : $.toJSON(c),
          tid : admin ? admin.href.replace(/.*?tid=(.*)/,'$1') : logout ? logout.href.replace(/.*?tid=(.*?)&.*/,'$1') : ''
    }, function(d) {
      callback && callback(d);
    }, 'json');
  };
  'par ange tuteur';
});



After that you'll be able to do this :
Code:
$updateField({
      id : 'field_id3',
    name : 'profile_field_8_3',
  user_id : 1,
    value : 0
}, function(d) {
  console.log(d); // log return data
});


It takes 4 values :
id : The id of the field. e.g. #field_id3
name : The name of the field. e.g. #profile_field_8_3
( both these ids can be found by inspecting the profile fields via your devtools ; F12 )
user_id : The id of the user to be modified.
value : The new value for the profile field. If it's a list of images you'll use numbers like in my example above. 0 = no warning, 1 = 1 warning, etc.. It depends how your images are ordered.

Lastly you can execute a callback function and check the return data which is in JSON format.

Back to top