Title: using wordpress function getblog_info() in external php file
Last modified: August 19, 2016

---

# using wordpress function getblog_info() in external php file

 *  Resolved [artflutter](https://wordpress.org/support/users/artflutter/)
 * (@artflutter)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/)
 * I am writing a plugin which is a contact form. The action of the form is to call
   send.php which parses the information and sends an email. In this file I want
   to use the code
    `<?php $fromsite = get_bloginfo('name'); ?>` but i’m getting
   a function not recognised error on get_bloginfo. What do I need to do to get 
   this php script to be able to use wordpress’ functions?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [artflutter](https://wordpress.org/support/users/artflutter/)
 * (@artflutter)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762766)
 * I have viewed pretty much all the wordpress contact form but thus far have been
   unable to figure out how to resolve this problem.
 * my contact forms main php file is called myplugin.php, when you click submit 
   it is processed by another php file called send.php. I assume that in my original
   php file I need to somehow let wordpress know that send.php is also part of the
   plugin and I want it to be able to use wordpress’ functions. But how do I do 
   this?
 *  [adamh](https://wordpress.org/support/users/adamh/)
 * (@adamh)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762770)
 * Instead of using send.php, why not have the contact form post to itsself (myplugin.
   php). Then in myplugin, have an ‘if’ statement to see if the form has been posted
 *     ```
       if($_REQUEST['message']) {
       /* send the contact form */
       /if
       ```
   
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762771)
 * if youre passing variables from one file to another you need to set the vars 
   as globals.
 * (see variable scope posts) >>
 * [http://wordpress.org/search/scope?forums=1](http://wordpress.org/search/scope?forums=1)
 * wordpress doesnt need to know that file B is part of the plugin, it doesnt care.
 * In the above example, this:
 * $fromsite = get_bloginfo(‘name’);
 * ought to be set in File A, and passed to File B as a global …
 * Or ..
 * The most common is to use functions, define the vars within those functions, 
   and then instead of writing a whole big routine into a file, you just call a 
   function – where everything is already defined.
 *  Thread Starter [artflutter](https://wordpress.org/support/users/artflutter/)
 * (@artflutter)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762780)
 * thanks for the replies, adamh I initially had my contact form within one html
   file but I had problems implementing the ajax sumbit and the only way I was able
   to fix it was to seperate the front-end from the back-end.
 * In my second file I am accessing the variables using $_POST[‘varname’] so I can
   just add to my original form using hidden inputs like
 * `<input type="hidden" name="blogname" value="$blogname">`
 * The only problem with using that method is that one of the variables that I want
   to pass is an email address using get_the_author_email(). Using a hidden input
   in the form means that anyone can view this email address by viewing the page
   source. Is there an alternative way to post this variable?
 *  Thread Starter [artflutter](https://wordpress.org/support/users/artflutter/)
 * (@artflutter)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762891)
 * whooami I was hoping you’d be able to elaborate further on how I can set $fromsite
   = get_bloginfo(‘name’); as a global in file a, so I can access it in file b.
 * file a is basically a form plus my variable $fromsite.
 *     ```
       <?php $fromsite = get_bloginfo('name'); ?>
       <form name="form" action="fileb.php>
       <input type="submit/>
       </form>
       ```
   
 * and lets say in file b I just want to echo the variable
    `<?php echo $fromsite?
   >`
 * What code do I need to add to make $fromsite accessible from fileb?
 *  [adamh](https://wordpress.org/support/users/adamh/)
 * (@adamh)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762899)
 * You could just use
 * `$_SESSION['blogname'] = get_bloginfo('name')`
 * in file a (assuming session_start() has been called by wp). Then, in file b
 *     ```
       session_start(); \\ at the very top
       echo $_SESSION['blogname'];
       ```
   
 *  Thread Starter [artflutter](https://wordpress.org/support/users/artflutter/)
 * (@artflutter)
 * [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762913)
 * Hi adamh, thanks for the tip but unfortunately it didn’t work for me. I’m sure
   it would be possible to get it working but I think at the moment I’ll just leave
   things as they are.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘using wordpress function getblog_info() in external php file’ is closed
to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 7 replies
 * 3 participants
 * Last reply from: [artflutter](https://wordpress.org/support/users/artflutter/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/using-wordpress-function-getblog_info-in-external-php-file/#post-762913)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
