Title: Custom Admin Approval Script
Last modified: December 9, 2024

---

# Custom Admin Approval Script

 *  Resolved [lowertownmedia](https://wordpress.org/support/users/lowertownmedia/)
 * (@lowertownmedia)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/custom-admin-approval-script/)
 * Greetings.
 * I am in need of using the features available in Google Forms to perform the “
   user registration” for new users in WordPress. Using make.com I successfully 
   can create new users from the Google form data with a prof builder user approval
   status of “pending”. Once approved I want a custom script to run to enclose the
   link to WordPress’s native reset password link (as a way to force the user to
   change their password) in the user approval email body. My various php scripts
   always result in the error “No {{reset_url}} placeholder found in email content”
   even though the placeholder is included in the email customizer for user approval.
 *     ```wp-block-code
       <?php/** * Plugin Name: Custom Admin Approval for Profile Builder * Description: Customizes email content and handles reset URL replacement for Profile Builder's admin approval process. * Version: 1.0 * Author: Your Name */// Hook into the 'wppb_send_email' filter.add_filter('wppb_send_email', 'replace_reset_url_in_email', 10, 2);/** * Replaces the {{reset_url}} placeholder in email content and ensures the user's name/email is included. * * @param array $email_args Email arguments array. * @param int   $user_id The ID of the user. * @return array Modified email arguments. */function replace_reset_url_in_email($email_args, $user_id) {    // Log debug info for troubleshooting    error_log(">>> wppb_send_email filter triggered for user ID: $user_id");    // Ensure user and reset URL can be retrieved    $user = get_user_by('id', $user_id);    if (!$user) {        error_log(">>> User not found for ID: $user_id");        return $email_args;    }    // Generate the reset URL    $reset_key = get_password_reset_key($user);    if (is_wp_error($reset_key)) {        error_log(">>> Error generating reset key for user ID: $user_id");        return $email_args;    }    $reset_url = wp_login_url() . "?action=rp&key=$reset_key&login=" . rawurlencode($user->user_login);    error_log(">>> Generated Reset URL for user ID $user_id: $reset_url");    // Replace {{reset_url}} in email content or add fallback    if (strpos($email_args['message'], '{{reset_url}}') !== false) {        $email_args['message'] = str_replace('{{reset_url}}', $reset_url, $email_args['message']);    } else {        error_log(">>> Placeholder {{reset_url}} not found. Adding reset URL explicitly.");        $email_args['message'] .= "<br><br>You can reset your password using this link: $reset_url";    }    // Add user's email or name dynamically in "Dear" section    $user_name = $user->display_name ? $user->display_name : $user->user_email;    if (strpos($email_args['message'], '{{user_email}}') !== false) {        $email_args['message'] = str_replace('{{user_email}}', $user_name, $email_args['message']);    } else {        $email_args['message'] = "Dear $user_name,<br>" . $email_args['message'];    }    // Log final email content for verification    error_log(">>> Final email content for user ID $user_id: " . $email_args['message']);    return $email_args;}
       ```
   
 * I’ve been trying to use the hooks listed on the prof builder support page to 
   the best of my ability, but the {{reset_url}} placeholder continues to echo no
   value in the email body.
 * Your help is appreciated in advance.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Georgian Cocora](https://wordpress.org/support/users/raster02/)
 * (@raster02)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/custom-admin-approval-script/#post-18189491)
 * Hello [@lowertownmedia](https://wordpress.org/support/users/lowertownmedia/),
 * The hook you are using is wrong, this only determines if the email should be 
   sent or not but it doesn’t filter it’s content.
 * You should try to use the filter from the next line for this:
 *     ```wp-block-code
       $message = apply_filters( 'wppb_email_message', $message, $context );
       ```
   
 * But there’s also a specific filter that runs over the content of the Admin Approval
   Approve email:
 *     ```wp-block-code
       wppb_new_user_status_message_approved
       ```
   
 * Please take note that these forums are here to offer help to our free version
   users, if you have further questions please direct them to our Support Form instead:
   [https://www.cozmoslabs.com/support/open-ticket/](https://www.cozmoslabs.com/support/open-ticket/)
 * Regards.

Viewing 1 replies (of 1 total)

The topic ‘Custom Admin Approval Script’ is closed to new replies.

 * ![](https://ps.w.org/profile-builder/assets/icon-256x256.png?rev=2961144)
 * [User Profile Builder - Beautiful User Registration Forms, User Profiles & User Role Editor](https://wordpress.org/plugins/profile-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/profile-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/profile-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/profile-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/profile-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/profile-builder/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Georgian Cocora](https://wordpress.org/support/users/raster02/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/custom-admin-approval-script/#post-18189491)
 * Status: resolved