404
Page not found.
> /** * Plugin Name: Custom Profile Login and Registration * Plugin URI: https://example.com/ * Description: A lightweight standalone plugin providing frontend login and registration via shortcodes. * Version: 1.0.0 * Author: Developer * License: GPL2+ */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } // 1. LOGIN FORM SHORTCODE function custom_login_form_shortcode() { if ( is_user_logged_in() ) { return '
You are already logged in. Log out
'; } $output = ''; // Handle login submission if ( isset( $_POST['custom_login_submit'] ) ) { // Verify nonce for security if ( ! isset( $_POST['custom_login_nonce'] ) || ! wp_verify_nonce( $_POST['custom_login_nonce'], 'custom_login_action' ) ) { $output .= 'Security check failed. Please try again.
'; } else { $creds = array( 'user_login' => sanitize_text_field( $_POST['custom_username'] ), 'user_password' => $_POST['custom_password'], 'remember' => true, ); $user = wp_signon( $creds, false ); if ( is_wp_error( $user ) ) { $output .= '' . esc_html( $user->get_error_message() ) . '
'; } else { wp_safe_redirect( home_url() ); exit; } } } // Render Login Form $output .= ' '; return $output; } add_shortcode( 'custom_login', 'custom_login_form_shortcode' ); // 2. REGISTRATION FORM SHORTCODE function custom_register_form_shortcode() { if ( is_user_logged_in() ) { return 'You are already logged in and registered.
'; } $output = ''; // Handle registration submission if ( isset( $_POST['custom_register_submit'] ) ) { // Verify nonce for security if ( ! isset( $_POST['custom_register_nonce'] ) || ! wp_verify_nonce( $_POST['custom_register_nonce'], 'custom_register_action' ) ) { $output .= 'Security check failed. Please try again.
'; } else { $username = sanitize_user( $_POST['reg_username'] ); $email = sanitize_email( $_POST['reg_email'] ); $password = $_POST['reg_password']; $password_confirm = $_POST['reg_password_confirm']; if ( empty( $password ) || $password !== $password_confirm ) { $output .= 'Passwords do not match.
'; } elseif ( username_exists( $username ) ) { $output .= 'Username already exists.
'; } elseif ( email_exists( $email ) ) { $output .= 'Email is already registered.
'; } else { $user_id = wp_insert_user( array( 'user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => 'subscriber' ) ); if ( is_wp_error( $user_id ) ) { $output .= '' . esc_html( $user_id->get_error_message() ) . '
'; } else { $output .= 'Registration successful! You can now log in.
'; } } } } // Render Registration Form $output .= ' '; return $output; } add_shortcode( 'custom_register', 'custom_register_form_shortcode' );Page not found.