Skip to:
Content
Pages
Categories
Search
Top
Bottom

Approve users by custom email


  • pulidomate
    Participant

    @pulidomate

    Hi!

    I would like admins (teachers) approve users (students) receiving an email when students send registration form (and must fill a teachers’ email). Is that possible?

Viewing 8 replies - 1 through 8 (of 8 total)

  • danbp
    Participant

    @danbp

    Hi @pulidomate,

    By default, it’s not possible. But you can try to code it.

    That said, registering users is reserved to site admin or editors. So far i understand your question, you’re talking about group admins (admins = teachers)and member types (teachers and students).

    Registration and user management is a core thing for users with WP roles/capabilities. It is not the same thing as Teachers and Students within BuddyPress.

    Group admins are, by default, users with a WP role of subscribers. Same thing for students. BP distinguish those users inside a group only, but for WP they still emain as “subscribers”.

    May be you can use a plugin, but i haven’t tested it. Try:
    https://wordpress.org/plugins/new-user-approve/


    pulidomate
    Participant

    @pulidomate

    It is not necessary teachers to be registered on the website. Only to receive an email to confirm that the student belongs to his college.

    I would like to do this: Student registres – send an email to the adressinserted by the student to registration form – approve the student with a link by this mail – student receives and email with the approvation.


    pulidomate
    Participant

    @pulidomate

    Finally i have done this:

    function activation_email( $subject, $message, $user_id, $user_email, $key ) {
        $teacher = bp_get_profile_field_data('field=Teacher&user_id='.$user_id);
        $activate_url = esc_url( $activate_url );
        $message = sprintf( __( "Thanks for registering! To complete the activation of this account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
        $user_email = $teacher;
    
        wp_mail( $user_email, $subject, $message );
    }
    add_action( 'bp_core_sent_user_validation_email', 'activation_email', 10, 5 );

    pulidomate
    Participant

    @pulidomate

    Anyone knows how can i do this with the new BuddyPress email API?


    danbp
    Participant

    @danbp

    Have you already read this ?

    Custom Emails


    pulidomate
    Participant

    @pulidomate

    Yes, but this code doesn’t work

    function activation_email( $user_id, $user_email, $key, $user_login = '' ) {
    
      $args = array(
        'tokens' => array(
          'key'          => $key,
          'user.email'   => $user_email,
          'user.id'      => $user_id,
        ),
      );
    
      if ( $user_id ) {
        $to = $user_id;
      } else {
        $to = array( array( $user_email => $user_login ) );
      }
    
        $teacher = bp_get_profile_field_data('field=Teacher&user_id='.$user_id);
    
        bp_send_email( 'core-user-registration', $teacher , $args );
    
    }
    add_action('bp_core_signup_send_validation_email','activation_email',99,4);

    pulidomate
    Participant

    @pulidomate

    missing the first value of array activate.url because this text editor show me an error when i copy that line


    pulidomate
    Participant

    @pulidomate

    Finally i have done this:

    function send_mail_to_teacher($user_id, $user_login, $user_password, $user_email, $usermeta){
    
      $key = get_user_meta( $user_id, 'activation_key', TRUE );
      $first_name = bp_get_profile_field_data('field=Name&user_id='.$user_id);
      $surname = bp_get_profile_field_data('field=Surname&user_id='.$user_id);
    
      $args = array(
        'tokens' => array(
          'key'          => $key,
          'user.email'   => $user_email,
          'user.id'      => $user_id,
          'first_name'   => $first_name,
          'surname'      => $surname,
        ),
      );  
    
      $teacher_email = bp_get_profile_field_data('field=Teacher&user_id='.$user_id);
    
      bp_send_email( 'sendtoteacher', $teacher_email, $args );
    
    }
    
    add_action('bp_core_signup_user', 'send_mail_to_teacher', 10, 5);
Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar