1

I am trying to write a custom php function for Wordpress that a custom Java program can access, the problem is anytime I try to use a WP function such as wp_hash_password it fails and returns a filenotfoundException.

The custom php file is sitting on the root directory of my wordpress installation and I have put

require(ABSPATH. 'wp-includes/pluggable.php');

at the top of the file so it would know where to find the function.

Am I missing something? Because even with the above file included, it is still failing.

IF I take out all wordpress functions it 'works'.

Maxime Pacary
  • 22,336
  • 11
  • 85
  • 113
Schwoebel
  • 216
  • 1
  • 4
  • 19

2 Answers2

1

Try something like this in addition for easier inclusion:

preg_match('/^(.+)wp-content\/.*/', dirname(__FILE__), $path);
include($path[1] . 'wp-load.php');
Olli Bolli
  • 347
  • 5
  • 15
1

ABSPATH is defined in wp-config.php - you'd have to require that as well.

I haven't tried it, but this page may help. Though according to the comment on this answer, just including wp-load.php may do the trick.

Community
  • 1
  • 1
Hobo
  • 7,536
  • 5
  • 40
  • 50
  • Thank you 100000000000 times. I would have never though to ask or search for those terms. I'm doing this on android and that is where my mind was. Thank you!!!! – Schwoebel Jan 19 '12 at 13:49