Title: Call a function I created?
Last modified: August 31, 2016

---

# Call a function I created?

 *  [gailwingate1](https://wordpress.org/support/users/gailwingate1/)
 * (@gailwingate1)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/call-a-function-i-created/)
 * Hi, I am not a php or js coder, but with a little help I’ve created the following
   php function using your plugin. I’m just not sure how to tell if it’s being called
   or do I need to place a call to this php function somewhere.
 * I need this run every time someone who is not logged in attempts to access content
   via a search engine referral. So if they clink on a link to content from Google,
   I need this function to run before displaying the content. Do I need to put a
   call to this function somewhere? If so where? I’ve created the function, but 
   it doesn’t seem to be working (ie I can still access the restricted content without
   being forced to the members login page).
 *     ```
       function redirect_from_search_engines() {
       	$url = parse_url( $_SERVER['HTTP_REFERER'] );
       	$sites = array( 'google', 'yahoo', 'bing' );
       	foreach( $sites as $site ) {
       		if ( ! stristr( $url['host'], $site ) ) continue;
   
       		$terms = get_the_terms( get_the_ID(), 'role' );
   
       		if ( (! is_user_logged_in()) and ( ! is_array( $terms ) || ! in_array( 'general-public', $terms ) ) ) continue;
   
       		wp-redirect('http://www.mders.org/my-membership-options');
       	}
       }
       add_action( 'wp', 'redirect_from_search_engines' );
       ```
   
 * Thank you!
 * [https://wordpress.org/plugins/my-custom-functions/](https://wordpress.org/plugins/my-custom-functions/)

The topic ‘Call a function I created?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/my-custom-functions_0e1030.svg)
 * [My Custom Functions](https://wordpress.org/plugins/my-custom-functions/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/my-custom-functions/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/my-custom-functions/)
 * [Active Topics](https://wordpress.org/support/plugin/my-custom-functions/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/my-custom-functions/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/my-custom-functions/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [gailwingate1](https://wordpress.org/support/users/gailwingate1/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/call-a-function-i-created/)
 * Status: not resolved