• Plans & Pricing
  • Log in
  • Get started
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress 
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Get started
  • Sign up
  • Log in
About
  • Plans & Pricing
Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Newsletter
  • Professional Email
  • Website Design Services
  • Commerce
  • WordPress Studio
  • Enterprise WordPress  
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • Support Center
  • WordPress News
  • Business Name Generator
  • Logo Maker
  • Discover New Posts
  • Popular Tags
  • Blog Search
Jetpack App
  • Learn more
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Search
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
Forums / How to create a custom wordpress plugin for a specific functionality?

How to create a custom wordpress plugin for a specific functionality?

  • Unknown's avatar
    techyparas · Member · Oct 25, 2022 at 6:05 pm
    • Copy link Copy link
    • Add topic to favorites Add topic to favorites

    I want to create a custom plugin to add a login with url functionality to my wordpress sites.

    For example, I want to create a link as follows:

    http://www.mysite.com/wp-admin?username=xxxx&pass=xxxxx

    For implementing this i found a code which is to be added to funtions.php file of any theme or plugin. The code is:

    <?php
    if( isset($_GET['username']) and $_GET['pass'] ) {
        $user = get_user_by('login', $_GET['username']);
    
        if ( $user && wp_check_password( $_GET['pass'], $user->data->user_pass, $user->ID) ) {
            wp_set_current_user($user->ID, $user->user_login);
            wp_set_auth_cookie($user->ID);
            do_action('wp_login', $user->user_login);
    
            wp_redirect( admin_url() );
            exit;
        }
    
        wp_redirect( home_url() );
        exit;
    }
    ?>

    But instead of hampering the files of any theme or plugin i want to create a custom plugin to add this functionality.

    Also by doing this i will be able to just simply install that plugin to all of my sites to add that functionality without hampering the code of any other plugin or theme.

    I tried to create a plugin named TechyParas to add this. But sadly it hasn’t worked. The code i added to my plugin was:

    <?php
    /*
    * Plugin Name: TechyParas
    * Description: This plugin will display a fixed link on the footer of your website.
    * Version: 1.0.0
    * Author: TechyParas
    * Author URI: https://techyparas.com
    * License: GPL2
    */
    function techyparas_log(){
    if( isset($_GET['username']) and $_GET['pass'] ) {
        $user = get_user_by('login', $_GET['username']);
    
        if ( $user && wp_check_password( $_GET['pass'], $user->data->user_pass, $user->ID) ) {
            wp_set_current_user($user->ID, $user->user_login);
            wp_set_auth_cookie($user->ID);
            do_action('wp_login', $user->user_login);
    
            wp_redirect( admin_url() );
            exit;
        }
    
        wp_redirect( home_url() );
        exit;
    }}
    add_filter('loginout', 'techyparas_log'); 
    ?>

    Please help me with this.

  • Unknown's avatar
    staff-doublebassd · Staff · Oct 26, 2022 at 4:06 pm
    • Copy link Copy link

    Hi there,

    This question would be best posed in the dotorg community forums here:

    https://wordpress.org/support/forum/wp-advanced/

    You’re posting in the Managed WordPress.com forums and we’re limited in the support we could provide in regard to plugins. But, the self-hosted forums would definitely be able to assist.

    Hope this helps.

  • Unknown's avatar
    techyparas · Member · Oct 26, 2022 at 4:21 pm
    • Copy link Copy link

    Thanks for your reply. I have posted this there too so that i can receive help as soon as possible.

  • The topic ‘How to create a custom wordpress plugin for a specific functionality?’ is closed to new replies.

Tags

  • .org
  • plugins functions login url
  • theme

About this topic

  • In: Support
  • 2 participants
  • 2 replies
  • Last activity 3 years
  • Latest reply from techyparas

Couldn't find what you needed?

Contact us

Get answers from our AI assistant, with access to 24/7 expert human support on paid plans.

Browse our guides

Find step-by-step solutions to common questions in our comprehensive guides.

WordPress.com

Products
  • WordPress Hosting
  • WordPress for Agencies
  • Become an Affiliate
  • Domain Names
  • AI Website Builder
  • Website Builder
  • Create a Blog
  • Professional Email
  • Website Design Services
  • WordPress Studio
  • Enterprise WordPress
Features
  • Overview
  • WordPress Themes
  • WordPress Plugins
  • WordPress Patterns
  • Google Apps
Resources
  • WordPress.com Blog
  • Business Name Generator
  • Logo Maker
  • WordPress.com Reader
  • Accessibility
  • Remove Subscriptions
Help
  • Support Center
  • Guides
  • Courses
  • Forums
  • Contact
  • Developer Resources
Company
  • About
  • Press
  • Terms of Service
  • Privacy Policy
  • Do Not Sell or Share My Personal Information
  • Privacy Notice for California Users
DeutschEspañolFrançaisBahasa IndonesiaItalianoNederlandsPortuguês do BrasilSvenskaTürkçeРусскийالعربيةעִבְרִית日本語한국어简体中文繁體中文English

Mobile Apps

  • Download on the App Store
  • Get it on Google Play

Social Media

  • WordPress.com on Facebook
  • WordPress.com on X (Twitter)
  • WordPress.com on Instagram
  • WordPress.com on YouTube

Automattic

Automattic
Work With Us
    • WordPress.com Forums
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • Manage subscriptions