• Resolved ukndoit

    (@ukndoit)


    I am creating a php code to listen for a post from a webhook.

    So I put it in mu-plugin since it will execute and never be overwritten when updates happen.

    I have never created a plugin, so no idea how to do it with a plugin.

    My question is, if it finds a post from the webhook, then does what I need it to, then have it print the header with 200 ok, then exit, why won’t the things that wp does work, such as:

    wp_create_user( $_user_name, $random_password, $_user_name );

    That code causes my site to get an error.
    if I put the // in front, no error. if I let it do it, I do get an error.

    Also other things did not work, such as get_user_by did not work, but creating this function:

    function get_user_by( $field, $value ) {
        $userdata = WP_User::get_data_by( $field, $value );
     
        if ( ! $userdata ) {
            return false;
        }
     
        $user = new WP_User;
        $user->init( $userdata );
     
        return $user;
    }

    that does work… so how do I do this:
    wp_create_user( $_user_name, $random_password, $_user_name );

    if it does not work?

    Is there a better way to create some code that would work, without using the mu-plugin?

    Thanks,
    -Richard

Viewing 1 replies (of 1 total)
  • Thread Starter ukndoit

    (@ukndoit)

    I FIXED IT ?? ?? ??

    used the add_action to create a function…

    that fixed it.

    not sure if it prints the header 200 ok or not… the way it needs to, and not sure how to test that, but so far so good.

Viewing 1 replies (of 1 total)
  • The topic ‘Must Use Plugins – mu-plugins help’ is closed to new replies.