Announcement

Collapse
No announcement yet.

Is it possible to get the userID of the current vB5 user, without coding a full-fledged vB5 plugin/extension/product?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is it possible to get the userID of the current vB5 user, without coding a full-fledged vB5 plugin/extension/product?

    I need to create a BB code that loads an iframe (very much like video embedding BB codes do), but I need to include the vBulletin userID of the current user as a parameter in the URL loaded in this iframe.

    I therefore need to know if there is any way to access the userID of the currently logged in vBulletin 5 user, and use it in the HTML of my custom BB code, without coding a full-fledged vB5 plugin/extension/product?

    Is there?

  • #2
    The currently viewing user's ID will be in the Javascript pageData object. You can access that object with your own Javascript.

    The code restricts a BBCode's replacement text to 200 characters at this time. That could be a severe limitation.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      Ok, sounds great!

      Will I be able to run arbitrary javascript code inside BB codes then to access this you say, and will this work equally well also when users are accessing my forum and viewing these posts from my vBulletin Mobile Suite mobile apps too?

      Comment


      • #4
        You can put whatever you want within 200 characters in the replacement field when creating a custom BBCode in the AdminCP.

        If you're implementing your BBCode using some other method, then you will need a full addon product so it can be properly registered and parsed with the code.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API - Full / Mobile
        Vote for your favorite feature requests and the bugs you want to see fixed.

        Comment


        • #5
          Ok, excellent, thanks!

          Comment


          • #6
            Originally posted by Wayne Luke View Post
            You can put whatever you want within 200 characters in the replacement field when creating a custom BBCode in the AdminCP
            Is it new? In the latest versions of 5.5x only? Can we change this max value somewhere in the code?

            I have a custom BBcode with over 200 characters in the replacement field for my version 5.5.0 and I am very happy with that.
            Last edited by lange; Sun 11th Aug '19, 11:19am.

            Comment


            • #7
              Maybe it was inadvertently fixed. I have an open issue on it so will have to recheck it.
              Translations provided by Google.

              Wayne Luke
              The Rabid Badger - a vBulletin Cloud demonstration site.
              vBulletin 5 API - Full / Mobile
              Vote for your favorite feature requests and the bugs you want to see fixed.

              Comment


              • #8
                For the record, a free characters counter online is showing 570 characters on my 5.5.0 custom BBcode (empty spaces included).

                Comment


                • #9
                  Originally posted by Wayne Luke View Post
                  You can put whatever you want within 200 characters in the replacement field when creating a custom BBCode in the AdminCP.

                  If you're implementing your BBCode using some other method, then you will need a full addon product so it can be properly registered and parsed with the code.
                  I've tried this now, but Javascript doesn't execute when viewing posts in the Mobile Suit apps, so it's not showing up there, even though it works when viewing the forum post in a web browser.

                  So, how would I be able to access/output the pageData.userid Javascript value in a post when viewed from the mobile apps too?

                  If completely impossible, isn't there any other way to get hold of the user's UserID from a BB code?

                  Since Javascript seems to be inaccessible from the Mobile Suite apps, I guess the only option would be to extract the user ID on the server side then?

                  Is it possible to create custom (PHP based) BB codes in vBulletin 5? I read somewhere that this is only possible in vB4, but impossible in vB5, is this true? Otherwise, how?

                  And to clarify, what I want is a BB code that outputs the User ID of the user viewing the thread, so that I could output something like:

                  "Your user ID is: 1234"

                  Which would display a different number for each different user viewing the thread (that is, their own user ID).
                  Last edited by vbSuperfan; Wed 21st Aug '19, 5:28pm.

                  Comment


                  • #10
                    You can't create modifications for the Mobile Suite. If you want the value available to the Mobile Suite through a BBCode, you will need to extend the output sent to the Mobile Suite via a PHP Extension/Product to the core system.
                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud demonstration site.
                    vBulletin 5 API - Full / Mobile
                    Vote for your favorite feature requests and the bugs you want to see fixed.

                    Comment


                    • #11
                      Originally posted by Wayne Luke View Post
                      If you want the value available to the Mobile Suite through a BBCode, you will need to extend the output sent to the Mobile Suite via a PHP Extension/Product to the core system.
                      Thanks, that's what I was afraid of...

                      So, regarding my questions about this in my last post, I assume then by your reply Wayne that it is indeed possible to create such a PHP Extension/Product for vBulletin 5, that can execute custom PHP code for a BBcode?

                      Does anyone have any tips for a good starting point (code skeleton or perhaps at least a little bit more specific discussion) for creating a vB5 PHP Extension/Product that can make a special PHP-backed BBcode like this (I am a PHP programmer, so I just need to know where to "hook in"...)?

                      Comment


                      • #12
                        There are example products included in the vBulletin download package under do_not_upload/development. I believe there is a package skeleton available at vBulletin.org. You can also look at the /core/packages directory for examples. For your specific purpose, you will probably want to extend vB_Api_Bbcode at /vb/api/bbcode.php and/or the bbcode library class at /core/vb/library/bbcode.php.
                        Translations provided by Google.

                        Wayne Luke
                        The Rabid Badger - a vBulletin Cloud demonstration site.
                        vBulletin 5 API - Full / Mobile
                        Vote for your favorite feature requests and the bugs you want to see fixed.

                        Comment


                        • #13
                          Thanks Wayne, I will take a look at those!

                          PS.
                          What's the difference between a "package" and a "product"?

                          Comment


                          • #14
                            A product is what is installed in the vBulletin AdminCP. A product can include PHP code, templates (stored in the database), CSS (custom templates), phrases, settings, Admin Help, and other items in the system. Most of this is shipped in a single XML file that can be imported into vBulletin.

                            A package is the PHP and XML code that allows that product to exist. vBulletin will scan the /core/packages directory and make products that exist here available to the system.
                            Translations provided by Google.

                            Wayne Luke
                            The Rabid Badger - a vBulletin Cloud demonstration site.
                            vBulletin 5 API - Full / Mobile
                            Vote for your favorite feature requests and the bugs you want to see fixed.

                            Comment


                            • #15
                              Ok, I see, thanks for the explanation!

                              Comment

                              Related Topics

                              Collapse

                              Working...
                              X