• Resolved maxmostovoy

    (@maxmostovoy)


    Hello, is it possible to get code and send it in another sevice, for example, by sms sender service.
    The question about how I can get code, maybe by hook, and then use it for my needed.
    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author dominic_ks

    (@dominic_ks)

    Hello,

    Yes I think we could look at adding a hook that fires once a code is set and ready to be sent by email.

    If you needed something more urgently and were happy with the email going as well, or used some other method of blocking it, you could use the bdpwr_code_email_text filter to send an SMS or something, e.g.

    
    add_filter( 'bdpwr_code_email_text' , function( $text , $email , $code , $expiry ) {
      //send an SMS with the same text or make some new text with the $code and $expiry
      //just make sure that you still return the $text for the email...
      return $text;
    }, 10 , 4 );
    
    Thread Starter maxmostovoy

    (@maxmostovoy)

    Thank you very much for your fast reply, I’ll try it, its seems exactly what I need now.
    And could your explain, is there way to disable emails in this case?
    Thanks.

    Plugin Author dominic_ks

    (@dominic_ks)

    No problemo.

    If you don’t need any emails to be sent from WordPress you can stop all emails with a plugin like this:

    If you need to stop individual emails, this is a bit of a hack I guess but I believe you can set the “To” email address to empty, or any invalid email address, in the wp_mail hook. I haven’t used this a lot so you’d probably need to test this, here’s an example:

    
    //set the email subject to something easy to catch
    add_filter( 'bdpwr_code_email_subject' , function( $subject ) {
      return 'no-send';
    }, 10 , 1 );
    
    //catch emails with this subject and set the "To" address to empty
    add_filter( 'wp_mail' , function( $args ) {
    
      if( $args['subject'] === 'no-send' ) {
        $args['to'] = false;
      }
    
      return $args;
    
    }, 10 , 2 );
    
    

    Again, not tested, and a bit of a hack, but if this works for you for now I’ll close this and raise a ticket on GitHub for it, if not, I’ll try and do something sooner.

    Let me know if it works for you either way!

    Thread Starter maxmostovoy

    (@maxmostovoy)

    Thank you. I’ll try it and reply you.

    Thread Starter maxmostovoy

    (@maxmostovoy)

    Hello, I’ll try your code, and it works fine.

    Sorry, but I have one more question)

    Is it possible to avoid checking user by email for using personal handling. Maybe its recommendation for future updaings. for example cheking user by email or name or custom field.

    Plugin Author dominic_ks

    (@dominic_ks)

    Hello,

    Thanks for feeding back, glad to hear that it works. I have created two items on GitHub that cover what we have been discussing here:

    Re: your last point, I guess this would be possible, though I think it’d have to be done at least using a field that was unique to the user. I’m wondering actually if I should just make the plugin more extensible so that people can use their own method of validating requests rather than me trying to cover all the scenarios. So, I’m not sure on this one at the moment and raised another ticket to look at when I or others are able to:

    Hoping that all your issues have been covered for now?

    Thanks,

    Thread Starter maxmostovoy

    (@maxmostovoy)

    Thank you very much. Yes, thats all I need now.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Ability to send code to phone’ is closed to new replies.