I’m trying to develop a code to call some Codex functions (https://codex.wordpress.org/Function_Reference) the problem is simple, I don’t find any doc where read about how to start.

I have a PHP file with this line for example:

<?php

 $website = "http://example.com";
 $userdata = array(
 'user_login'  =>  'login_name',
 'user_url'    =>  $website,
 'user_pass'   =>  NULL  // When creating an user, `user_pass` is expected.
);

 $user_id = wp_insert_user( $userdata ) ;

 //On success
 if ( ! is_wp_error( $user_id ) ) {
 echo "User created : ". $user_id;
 }

?>

Where I need to put this code to check if works?
Where I need to call it?
Must I create a plugin? Can I call those functions from a script in a specific folder?

For example, the funcion wp_insert_user is in /wp-includes/user.php, can I call the function just including the script?

include('user.php')

Where are the rest of the functions?

Someone knows an specific manual with a simple doc? I’m getting crazy.

This is my first script for a CMS and I don’t undertand how it works, but I dont find manuals or simple doc.

2 s
2

I get the solution.

To call functions from WordPress from a custom script, you need to import wp-load:

require_once("/path/wp-load.php");

Thats all, I can work fine with those functions. I save my own script in the root of my PHP WordPress and I didn’t need a plugin.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *