• Resolved 1jd123

    (@1jd123)


    Dear all,

    i need to automatize the process auf resending the activation mail after 4 – 7 and 14 days. But the code i provide is not working.

    add_action( ‘wp_ajax_resend_activation_email’, ‘resend_activation_email’ ); function resend_activation_email() { if (isset($_POST[’email’])) { $email = $_POST[’email’]; // Check if the email is valid if (filter_var($email, FILTER_VALIDATE_EMAIL)) { // Call the function and check if it is successful if(custom_wp_new_user_notification_email( null, (object) array( ‘user_email’ => $email, ‘user_login’ => $email ), ” )) { wp_send_json_success(); } else { error_log(“custom_wp_new_user_notification_email function failed”); wp_send_json_error(“custom_wp_new_user_notification_email function failed”); } } else { error_log(“Invalid email format: $email”);}}

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @1jd123

    Hope you are doing well!

    We’ll need to verify with the team if resending the activation email can be achieved using a specific hook or if additional custom code may be necessary. I have escalated this request to our Second Level Support Team, so they can provide further help and check if this is possible.

    Please keep in mind the Second Level Support team works with more complex issues and their response may take some considerable time. Once they have an update a notification will be sent and a post will also be added in the ticket thread.

    Thanks in advance for your patience on this matter.

    Kind regards

    Luis

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @1jd123

    Our Second Level Support team has provided a custom code that can help resend the activation mail.

    You’ll need to add a must-use plugin to your site’s wp-content/mu-plugins folder as explained in our documentation here: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins, then add the following code provided to the plugin’s php file:

    add_action('admin_init', 'wpmudev_resend_activation_link');
    function wpmudev_resend_activation_link() {
    	if ( ! current_user_can( 'manage_options' ) ) {
    		return;
    	}
    
    	if ( isset( $_GET['page'] ) ) {
    		if ( $_GET['page'] == 'forminator-entries' && isset( $_GET['form_id'] ) ) {
    			if ( ! isset( $_GET['formi_resend_notification'] ) ) {
    				return;
    			}
    
    			global $wpdb;
    			
    			$form_id 		  = $_GET['form_id'];
    			$table_name       = Forminator_Database_Tables::get_table_name( Forminator_Database_Tables::FORM_ENTRY_META );
    			$entry_table_name = Forminator_Database_Tables::get_table_name( Forminator_Database_Tables::FORM_ENTRY );
    			$sql              = "SELECT m.meta_value FROM {$table_name} m LEFT JOIN {$entry_table_name} e ON(e.entry_id = m.entry_id) WHERE e.form_id = %d AND m.meta_key = %s AND ( e.draft_id IS NULL OR e.draft_id = '' ) AND e.is_spam = 0 order by m.meta_id";
    			$entry_ids        = $wpdb->get_results( $wpdb->prepare( $sql, $form_id, 'activation_key' ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    			if ( ! empty( $entry_ids ) ) {
    				foreach ( $entry_ids as $entry ) {
    					$activation_key = $entry->meta_value;
    					if ( ! empty( $activation_key ) ) {
    						$url = add_query_arg(
    							array(
    								'page' => 'account_activation',
    								'key'  => $activation_key,
    							),
    							home_url( '/' )
    						);
    			
    						$signup    = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}signups WHERE activation_key = %s", $activation_key ) );
    						if ( ! $signup->active ) {
    							$username  = $signup->user_login;
    							$recipient = $signup->user_email;
    				
    							$urlparts = parse_url( home_url() );
    							$domain   = $urlparts['host'];
    							$headers  = array(
    								'Content-Type: text/html; charset=UTF-8',
    								'From: ' . html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ) . ' <admin@' . $domain . '>',
    							);
    				
    							$subject  = sprintf( esc_html__( 'Activation link for %s', 'forminator' ), $username );
    							$message  = '<p>' . esc_html__( 'To activate your user account, please click the following link:', 'forminator' ) . '</p>';
    							$message .= '<p>' . esc_url_raw( $url ) . '</p>';
    							$message .= '<p>' . esc_html__( 'After you activate, you will receive *another email* with your login.', 'forminator' ) . '</p>';
    				
    							if ( ! empty( $recipient ) && ! empty( $subject ) && ! empty( $message ) ) {
    								$sent = wp_mail( $recipient, $subject, $message, $headers );
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    }

    After adding the snippet, need to visit the entries/submission page for instance (replace https://mylocal.loca with your domain):

     https://mylocal.local/wp-admin/admin.php?page=forminator-entries&form_type=forminator_forms&form_id=3461&paged=1 

    Add an extra parameter formi_resend_notification to trigger resending the notifications. So, the final URL should be like this

    https://mylocal.local/wp-admin/admin.php?page=forminator-entries&form_type=forminator_forms&form_id=3461&paged=1&formi_resend_notification

    Important: The form ID will be different (replace 3461 with your form id). Once page is reloaded, remove the formi_resend_notification parameter from the URL or else it will re-send all the notifications again.

    Hope this information helps. Feel free to reply if you have further questions or concerns.

    Kind regards

    Luis

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @1jd123 ,

    We haven’t heard from you for over a week now, so it looks like you no longer need our assistance.

    Feel free to re-open this topic if needed.

    Kind regards
    Kasia

    Thread Starter 1jd123

    (@1jd123)

    Hello Kasia,

    I need some option to resend the activation mail automatically after the user hasn’t activated his account.
    This E-Mail should be sent after 3 Days, after 7 Days and after 14 Days.
    And this is a really crucial problem, so please support me in this case

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @1jd123,

    I hope you are doing well today!

    We are checking your request with our SLS team if it is possible to provide a solution or workaround and will inform you accordingly. Thank you for your patience while we look into this further.

    Kind regards,
    Zafer

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi again @1jd123,

    Regrettably, we would like to inform you that your request falls beyond the scope of our support services, as its adequate implementation necessitates significant customization, which extends beyond the provided code snippet.

    We therefore suggest seeking the assistance of a professional developer to help you accomplish this task. We appreciate your understanding regarding this matter.

    Kind regards,
    Zafer

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Activation E-Mail Hook does not work’ is closed to new replies.