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
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
Top Achievers
Who is online?
In total there are 16 users online :: 0 Registered, 0 Hidden and 16 Guests :: 1 Bot
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
[SOLVED] Using ajax to modify user profile
Page 1 of 1 • Share
- Wolfuryo
- Gender :
Posts : 256
Points : 3597
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
Hello,
I'd like to know if there is any way to ajax edit users profiles.
Example:I am user 1 and I want to modify user's 2 profile without going to his profile, but clicking a button.
P.S.:I need this for a warning system.
Tagging @Ange Tuteur
I'd like to know if there is any way to ajax edit users profiles.
Example:I am user 1 and I want to modify user's 2 profile without going to his profile, but clicking a button.
P.S.:I need this for a warning system.
Tagging @Ange Tuteur
@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 :
After that you'll be able to do this :
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.
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.
- Wolfuryo
- Gender :
Posts : 256
Points : 3597
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
Thanks you. It's working well.
- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum