Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Javascript: Add Instagram as contact field to your forum

Recommended Posts

Add Instagram as contact field to your forum

Hello dear all,

In this tutorial I will show you an easy way, to create an Instagram field for your forum and have it to the contact information with the rest social media information.



First of all, this new field will be exactly like the Facebook field. That means you only have to add the extension to the link. (Example: If my profile is

then I only add

to the field) The rest will be done automatically.

Field Creation

First of all we have to create this field. So to do so, we go: Admin Panel > Users & Groups > Users - Profiles (and select the "Contact fields" tab) and press the   icon to create a new field. Then you have to fill in the information as below:

  • Name : Instagram (color of your choice)
  • Description : Optional
  • URL icon :

    (NOTE! This image url is necessary for our code.)
  • Necessarily filled ? Your decision
  • Display : Tick both Profiles and Messages (if you want the field to be shown on the profiles and in the messages)
  • Display type : Text
  • Who can modify the profile field value ? Tick both Moderators and Member himself (You can tick whatever you want)
  • Display this field for users that are at least : Your choice
  • Type : Web address
  • Default content : (leave blank)

And finally press the Save button. With that we are done with the profile.

Javascript Code

Now all we need, is a Javascript to make the field work as the Facebook field.
Before that, let's create the javascript. Go to: Admin Panel > Modules > HTML & JAVASCRIPT - Javascript codes management and make sure the Enable Javascript code management : is set to Yes and then press the CREATE A NEW JAVASCRIPT button to create your Javascript. Once you've created your javascript you only have to fill in the information as below to finish your work:

  • Title * : Instagram field addition
  • Placement : In all the pages
  • Javascript Code * : Copy and paste this code in your field:

    /* ------------------------------------------------------------------------

    **************** COPYRIGHTS ©️ 2018, LUFFY - FORUMOTION.COM ****************

    - Please do not try to post a new tutorial using this code to your forum.
    - This code is written by Luffy for Forumotion.com forums only.
    - Please ask your questions at https://help.forumotion.com
    - Please do not remove these comments.
    - Tutorial Link: /t156778-add-instagram-as-contact-field-to-your-forum
    --------------------------------------------------------------------------- */

     if(/\/?u(\d+)contact$/.test(location.pathname)) {
       $('dl#field_id1 dd a').attr('title','View the user\'s Instagram account');
       if ($('dl#field_id1 dd a[href*="http://"]')){
         var ifgr_instagram_src = $('dl#field_id1 dd a').attr('href').slice(7);
       if ($('dl#field_id1 dd a[href*="https://"]')){
         var ifgr_instagram_src = $('dl#field_id1 dd a').attr('href').slice(8);
       $('dl#field_id1 dd a').attr('href', 'https://www.instagram.com/' + ifgr_instagram_src);
     if (/t(\d+)/.test(window.location.pathname)) {
       $('a.InstagramPage').attr('title','View the user\'s Instagram account');
       if ($('a.InstagramPage[href*="http://"]')){
         var ifgr_instagram_src2 = $('a.InstagramPage').attr('href').slice(7);
       if ($('a.InstagramPage[href*="https://"]')){
         var ifgr_instagram_src2 = $('a.InstagramPage').attr('href').slice(8);
       $('a.InstagramPage').attr('href', 'https://www.instagram.com/' + ifgr_instagram_src2);

And then press the SUBMIT button to save the javascript. With this we are officially over.
BEFORE YOU CLOSE THE TOPIC: Please read the below information just in case something is not working properly.


These information are for forums that don't use the English language to their forum or use an other picture for the profile field. Please read the carefully.

  1. If you have created an other field in the Contact fields before then you have to check on the field id to correctly execute the code. This field id is used in the first section of the javascript where it says
    $('dl#field_id1 dd a')

    of which the

    is the field id. If you have an other id, all you have to do is replace it with yours and you will be fine. Note that this part is SIX times in the first part.
    How to check my field's id:
    Step 1: Press Right Click on the Instagram picture you just created and then click Inspect Element

    Then a new window will open where you have to see what field_id is written above the marked part that is shown

    Then you replace that field id number in your javascript.

  2. Then based on your language you should be able to see what it says on your website field on hover. (Example: the default website field says: "Visit poster's website". Now based on your language this text differs. This part, we need it for this part of the code:

    where you have to replace the word website with the word your forum has for the website field.
  3. Next up, right after the above code you will see this part

    which has the image url I mentioned above. Now if you change the image url to something else, you will have to add the exact url in this code and specifically replace the url

    with your new Instagram image url.
  4. Finally if you want to change the text Visit the user's Instagram account that appears when you hover your contact field then all you have to do is change this part
    .attr('title','View the user\'s Instagram account');

    and more specifically the
    View the user\'s Instagram account

    BE CAREFUL If you will use the

    or the

    symbols you have to add the escape slash

    before it or nothing will work as shown above.




That's all, and I hope you enjoyed the tutorial. Smile

Official tutorial link of English Support Forum: https://help.forumotion.com/t156778-add-instagram-as-contact-field-to-your-forum

© forumotion.com
  • Like 1

Share this post

Link to post
Share on other sites

  • Create New...