Announcement

Collapse
No announcement yet.

Question about calling PHP functions within a thread

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

  • Question about calling PHP functions within a thread

    Please keep in mind I do not know PHP and what I do know I've figured out from messing with vB for nigh 8 years.

    I want to be able to display information in a thread using PHP... I've figured out that I can't use PHP within the thread itself because it will not display, so I am using an iframe to call up the file which I am calling iframe.php.

    This is the code I am currently testing:

    PHP Code:
    <?php
    if ( $post[usergroupid] == ) {
        echo 
    "<font face='Tahoma' size='4' color='#FFFFFF'>This is a test using iframes and 
    php functions.</font>"
    ;
    }
    else {
        echo 
    "<font face='Tahoma' size='4' color='#FFFFFF'>You do not have permission to 
    access this page.</font>"
    ;
    }
    ?>
    Now, I am a member of Usergroupid 5 however it is displaying the else statement instead of showing me the info I want. Do I need to use some PHP command that links my statements? I am sort of figuring that the PHP doesn't know what $post[usergroupid] is, but I don't know how to link it to all the other vBulletin information.

    Help appreciated!

  • #2
    Here are instructions that will explain the procedure.

    http://www.vbulletin.com/docs/html/m..._externalfiles

    Comment


    • #3
      This seems like a great way to include files to specific templates, however, I want it to work differently in specific threads. I want to restrict information in specific threads to certain usergroups, or show different information in the same thread for different usergroups.

      I don't see how I can make a global plugin work for different threads that would have different information in them.

      Comment


      • #4
        Originally posted by MoH672 View Post
        I don't see how I can make a global plugin work for different threads that would have different information in them.
        As described in the link I provided:

        2. Place $includedphp in one of your templates, such as header, navbar, FORUMHOME, depending upon where you want the contents of your PHP file to appear.
        This allows your php script to run just prior to threadbit or what ever template you choose.

        Comment


        • #5
          Thanks for your help, Andy.

          My script is still telling me I do not have permission to access the information, even though I am in the correct usergroup.

          I have installed the plugin and tried putting $includedphp in my headerinclude and postbit templates, but I am still unable to get it to work. Thoughts?

          Comment


          • #6
            Originally posted by MoH672 View Post
            Thanks for your help, Andy.

            My script is still telling me I do not have permission to access the information, even though I am in the correct usergroup.

            I have installed the plugin and tried putting $includedphp in my headerinclude and postbit templates, but I am still unable to get it to work. Thoughts?
            I've often run into situations where variables are not in the scope. So to get around this I run a query directly from my php script.

            You can get the userid from the users cookie and run a query to get the usergroupid. From the query result you execute the code you want.

            Comment


            • #7
              There is no $post[usergroupid], you must read the user information on the post and do is_member_of($the_user_information, 5); to have it work...

              Comment

              Loading...
              Working...
              X