Title: Help using a variable in a function parameter
Last modified: June 21, 2019

---

# Help using a variable in a function parameter

 *  Resolved [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/)
 * I have the following code in a plugin:
 *     ```
       if( $var != '' && !is_user_logged_in() ) {
       	if( is_child( $var ) ) {
       		auth_redirect();
       	}
       }
       ```
   
 * $var is functioning as intended on the page and I use it elsewhere in the template,
   but it’s not working when used as a parameter for the is_child() function.
 * If I put the ID number manually as the parameter.. it works perfectly.
 * Can someone help me figure out why please?
    -  This topic was modified 6 years, 11 months ago by [OthelloBloke](https://wordpress.org/support/users/othellobloke/).

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/?output_format=md)
[1](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/?output_format=md)
2

 *  Thread Starter [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/page/2/#post-11659071)
 * I did that. It showed me a bunch of errors about other random plugins, but not
   a single error about is_child.
 * I even deleted ALL of that code from the plugin, and is_child then gave me an
   undefined function error.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/page/2/#post-11659077)
 * That’s very strange, and not something that I can help with any more.
 * The problem is… you’re saying that there’s no other function called is_child(),
   but when you run the debugging code it’s saying that there _is_ another function
   called that, so something somewhere is not right on your side. Faced with that…
   there’s no other answers that I can give. Maybe someone else might have an idea.
 *  Thread Starter [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/page/2/#post-11659082)
 * It said there was another function because when you told me to try that, I didn’t
   erase all of the other code that initially defined it.
 * Thanks for your help anyway 🙂
 *  Thread Starter [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * (@othellobloke)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/page/2/#post-11659140)
 * I fixed it. I was using the ID, and just used the page slug and everything worked
   perfectly.
 * Legit appreciate your help mate.

Viewing 4 replies - 16 through 19 (of 19 total)

[←](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/?output_format=md)
[1](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/?output_format=md)
2

The topic ‘Help using a variable in a function parameter’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 19 replies
 * 2 participants
 * Last reply from: [OthelloBloke](https://wordpress.org/support/users/othellobloke/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/help-using-a-variable-in-a-function-parameter/page/2/#post-11659140)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
