Announcement

Collapse
No announcement yet.

Using Vbulletin syntax in PHP module

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using Vbulletin syntax in PHP module

    Hi all !

    I would like to know if it's possible to use the Vbulletin syntax (like <vb:if condition=""> for example) inside a Php module added via the Site builder ?
    Raw PHP is indeed working there, but Vb code isn't.

    I saw that glen posted this useful answer there :


    But I don't know if that apply to my case, I tried to add it, but I still can't get it to work.

    My current test code is the following :

    Code:
    global $vbulletin;
    echo '<b>test</b>';
    <vb:if condition="$bbuserinfo['usergroupid'] == '1' OR '6'">
    echo '<b>double test</b>';
    </vb:if>
    This is just, of course, to test the system and serve no other purpose as it is.

    Thanks in advance

    Cheers

    #2
    No you can't use vB syntax in PHP module. You can only use PHP syntax. vB syntax can only be used in vB templates.

    Try this instead:
    PHP Code:
    if ($bbuserinfo['usergroupid'] == '1') OR $bbuserinfo['usergroupid'] == '6') {
        echo 
    'hello';


    Not sure if $bbuserinfo variable is available in PHP module though. You can add this code to debug.
    PHP Code:
    var_dump($bbuserinfo); 
    Last edited by glennrocksvb; 02-16-2019, 11:41 AM.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      Thanks a lot for the quick answer Glen,

      Trying your code generate an error and I need to disable PHP, Static and Ad module rendering to remove the code in order to get it working again.
      The error is generic and the following :
      That action could not be completed. Please try again, and if this occurs again please contact the system administrator and tell them how you got this message.
      Is this related to maybe the variable not being available or just a syntax error ?

      Comment


        #4
        I have a syntax error in the code I posted earlier. Try this instead:

        PHP Code:
        if ($bbuserinfo['usergroupid'] == '1' OR $bbuserinfo['usergroupid'] == '6') {
            echo 
        'hello';

        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #5
          Thanks again Glenn,

          This doesn't not generate any error, however it doesn't work, with the var_dump, I get the result NULL, does that mean that this vb variable isn't available here ? Is there a way around that ?

          Thanks in advance

          Comment


            #6
            Depending on where we want to implement those conditionals, it would be interesting to have a list of variables ready for use in the vB5 templates as it was available on vBulletin.com for vB4 & vB3.

            Xenforo 2.0 already has a list of available variables.

            Comment


              #7
              I think you would need to call the user API to fetch the user info.
              PHP Code:
              $api Api_InterfaceAbstract::instance();
              $userInfo $api->callApi('user''fetchUserinfo', array());
              var_dump($userInfo); 

              By default, if userid is not passed, it will fetch the user info of the currently logged in user.
              Helpful? Donate. Thanks!
              Buy me a coffeePayPal QR Code
              Fast VPS Host for vBulletin:
              A2 Hosting & IONOS

              Comment


                #8
                Originally posted by glennrocksvb View Post
                I think you would need to call the user API to fetch the user info.
                PHP Code:
                $api Api_InterfaceAbstract::instance();
                $userInfo $api->callApi('user''fetchUserinfo', array());
                var_dump($userInfo); 

                By default, if userid is not passed, it will fetch the user info of the currently logged in user.
                Thanks, I'll try that !

                Comment

                Users Viewing This Page

                Collapse

                There is 1 user viewing this forum topic.

                • Guest Guest

                Latest Posts

                Collapse

                Working...
                X
                Searching...Please wait.
                An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

                Please push the back button and reload the previous window.'
                An unexpected error was returned: 'Your submission could not be processed because the token has expired.

                Please push the back button and reload the previous window.'
                An internal error has occurred and the module cannot be displayed.
                There are no results that meet this criteria.
                Search Result for "|||"