Hide Create Account Link
November 18, 2024 · AI Conversations
Here are a few methods to achieve this:
### Method 1: Custom CSS
You can hide the link using custom CSS by targeting the "Create Account" link. Add this CSS to your theme's `style.css` or via the **Customizer** (Appearance > Customize > Additional CSS):
/* Hide the create account link on the login page */
body.login #userswp-login-form .userswp-login-register-link {
display: none;
}
This CSS will target the registration link specifically on the login page.
### Method 2: Custom Code in `functions.php`
If you'd prefer to remove the link dynamically, you can add the following code to your theme's `functions.php` file or a custom plugin:
function remove_userswp_create_account_link() {
if ( is_page( 'login' ) ) { // Change 'login' to the actual login page slug if needed
remove_action( 'userswp_login_form_footer', 'userswp_login_register_link' );
}
}
add_action( 'wp', 'remove_userswp_create_account_link' );
This code removes the "Create Account" link from the login form by unhooking the action responsible for displaying it.
### Method 3: Using a Plugin (if you prefer a plugin-based approach)
If you want to use a plugin to manage this feature, you can install a custom login page plugin, such as **Custom Login Page Customizer** or **Theme My Login**, and then hide the registration link through the plugin's settings.
Let me know if you need further assistance with any of these methods!
### Steps to Add CSS in `wp_head`:
1. **Edit `functions.php`**:
Open your theme's `functions.php` file (located in `wp-content/themes/your-theme-name/functions.php`).
2. **Add the CSS Code**:
Add the following code to the `functions.php` file to inject custom CSS into the “ section of the site.
function add_custom_css_to_head() {
?>
<style>
/* Custom CSS */
body.login #userswp-login-form .userswp-login-register-link {
display: none;
}
</style>
<?php
}
add_action('wp_head', 'add_custom_css_to_head');
### Explanation:
– The `wp_head` action hook allows you to insert content inside the “ section of your HTML.
– The `add_custom_css_to_head` function outputs the custom CSS inside a “ tag.
– The CSS itself hides the "Create Account" link on the login page, as previously mentioned.
This approach ensures that the CSS is added directly in the page's “, and it’s dynamically loaded whenever the page is rendered.
Let me know if you need help with anything else!