• Resolved 00immortaldoesdev

    (@00immortaldoesdev)


    Hi. Somehow, the email goes if i add user via the front end users tab in dashboard. but it doesnt send when i add a user from backend, (with functions.php)

    This is what I used in functions.php

    function fb_wp_insert_user() {
    $user_data = array(
    'ID' => '',
    'user_pass' => wp_generate_password(),
    'user_login' => 'dummy',
    'user_nicename' => 'Dummy',
    'user_url' => '',
    'user_email' => '[email protected]',
    'display_name' => 'Dummy',
    'nickname' => 'dummy',
    'first_name' => 'Dummy',
    'user_registered' => '2010-05-15 05:55:55',
    'role' => get_option('default_role') // Use default role or another role, e.g. 'editor'
    );
    $user_id = wp_insert_user( $user_data );
    }
    add_action( 'admin_init', 'fb_wp_insert_user' );

    Am I doing something wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author bnfw

    (@voltronik)

    Hi @00immortaldoesdev,
    Thanks for your message.

    When you create the user in the WP Admin, are you just adding them via the Users screen and checking the box that says to send the user an email about their new account? Or are you creating them differently?

    Thread Starter 00immortaldoesdev

    (@00immortaldoesdev)

    I am adding them from functions.php file using the admin_init from wordpress directly.

    Plugin Author bnfw

    (@voltronik)

    Hi @00immortaldoesdev,
    I think we’re talking at cross purposes.

    To clarify, when I refer to the back-end, I mean the WordPress Admin. When I refer to the front-end, I mean the part of the site that site visitors see – i.e. not the WordPress Admin.
    The functions.php file is neither the WordPress Admin or the front-end as it is the underlying code of the website.

    With the above information, can you confirm that the WordPress Admin works but your function in the functions.php file doesn’t work?

    Thread Starter 00immortaldoesdev

    (@00immortaldoesdev)

    Yes I confirm

    Plugin Author bnfw

    (@voltronik)

    Hi @00immortaldoesdev,
    Ok, great.

    I think the issue is that you’re calling the function on admin_init which is too early in the process to trigger the notification.

    Have you tried hooking it off of another action, or running the wp_insert_user function directly instead, say after a page has refreshed?

    Plugin Author bnfw

    (@voltronik)

    Closing due to inactivity. If you need further help with this, please feel free to re-open this thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘New User Registration – For User not working when user added manually’ is closed to new replies.