• Resolved datto510

    (@datto510)


    Hello,

    We are trying to create a new registered user from the postie sender email address but without success.
    Can somebody have a look at this code and make any suggestions ?

    <?php
    function my_postie_post_function($post) {
        //do something here like update $post['post_content']
    
    add_filter('postie_filter_email', 'my_filterEmail');
    
    function my_filterEmail($email) {
        //create the user
    
    function my_postie_post_function($post) {
        //do something here like update $post['post_content']
    
    add_filter('postie_filter_email', 'my_filterEmail');
    
    function my_filterEmail($email) {
        //create the user
    
    $user_id = username_exists( $user_name );
    if ( !$user_id and email_exists($user_email) == false ) {
        $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
        $user_id = wp_create_user( $user_name, $random_password, $user_email );
    } else {
        $random_password = __('User already exists.  Password inherited.');
    }
    
        return $email;
    }
    
        return $post;
    }
    
    add_filter('postie_post_before', 'my_postie_post_function');
    
    }
    
        return $post;
    }
    
    add_filter('postie_post_before', 'my_postie_post_function');
    
    ?>

    Thanks

    https://wordpress.org/plugins/postie/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Wayne Allen

    (@wayneallen-1)

    You were trying to be too complicated

    <?php
    
    add_filter('postie_filter_email', 'my_filterEmail');
    
    function my_filterEmail($email) {
        //create the user
        $user = get_user_by('email', $email);
        if (empty($user)) {
            $user_name = strstr($email, '@', true);
            $userid = register_new_user($user_name, $email);
        }
    
        return $email;
    }
    
    ?>

    Note – I haven’t tested this

    Thread Starter datto510

    (@datto510)

    Thank you Wayne 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Register a user from email.’ is closed to new replies.