Hide WP Admin URL

User
admin_url('admin.php?page=userwp-user-approval')
wps hide login
we have change above wp-admin to focus_admin when send in emai;
Assistant
To modify the WordPress login URL and hide the standard admin URL, you can follow these steps:

1. **Hide the Default Login URL:**
You can use a plugin or add custom code to your theme's `functions.php` file to change the login URL. For example, you can use the "WPS Hide Login" plugin, which allows you to easily change the default login URL.

2. **Modify the Email Links:**
If you want to change the URL in emails sent by your WordPress site, you can filter the email content to replace the login URL with your custom one. Here’s a code snippet that you can add to your theme's `functions.php` file to achieve this:

add_filter('wp_mail', 'change_wp_email_links');
   
   function change_wp_email_links($args) {
       // Specify your custom admin URL
       $custom_admin_url = 'your-site-url/focus_admin';
       
       // Change the admin login URL in the email content
       if (isset($args['message'])) {
           $args['message'] = str_replace(admin_url('admin.php?page=userwp-user-approval'), $custom_admin_url, $args['message']);
       }
       
       return $args;
   }

Make sure to replace `your-site-url` with your actual site URL.

3. **Testing:**
After adding this code, test by triggering an email that includes the admin link to ensure it correctly replaces the URL with your custom `focus_admin` URL.

4. **Additional Considerations:**
Ensure that your custom login page (`focus_admin`) is set up correctly and that users can log in through it. If you’re using a custom login page, make sure it handles the authentication properly.

By following these steps, you should be able to hide the default admin login URL and replace it with your desired URL in emails sent from your WordPress site.

Assistant
To modify the login URL and replace `wp-admin` with `focus_admin` when sending emails from the UsersWP plugin, you can use a filter in your theme's `functions.php` file or a custom plugin. Here's an example of how to achieve this:

add_filter('userwp_approval_email', 'custom_userwp_approval_email', 10, 2);

function custom_userwp_approval_email($email_content, $user_id) {
    // Get the original login URL
    $login_url = admin_url('admin.php?page=userwp-user-approval');
    
    // Replace 'wp-admin' with 'focus_admin'
    $modified_login_url = str_replace('wp-admin', 'focus_admin', $login_url);
    
    // Customize the email content with the modified login URL
    $email_content .= "nnClick here to approve the user: " . $modified_login_url;

    return $email_content;
}

### Explanation:
1. **Hook into the Email Filter**: The `userwp_approval_email` filter allows you to modify the email content sent for user approvals.
2. **Get the Original Login URL**: Use `admin_url()` to get the default admin URL for the UsersWP approval page.
3. **Replace 'wp-admin' with 'focus_admin'**: Use `str_replace()` to change the URL.
4. **Modify the Email Content**: Append or modify the email content to include the new URL.
5. **Return the Modified Content**: Finally, return the modified email content.

### Implementation:
1. **Add the Code**: Place the above code snippet in your theme's `functions.php` file or in a custom plugin.
2. **Test the Email**: Ensure the email containing the modified login URL is sent correctly when a user approval email is triggered.

This will customize the email with the desired login URL format. If you need further adjustments or additional functionality, let me know!

Leave a Comment

Your email address will not be published. Required fields are marked *