Title: Plugin Code Question
Last modified: August 21, 2016

---

# Plugin Code Question

 *  [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/)
 * I am currently making a plugin that changes the default WP login page.
    Currently
   it is in very early stages. To change the WP logo on the login page, one has 
   to do it inside the code. Could someone help me/give me required code to add 
   some settings for the plugin. I want to have a box where users can add images
   from the media center and the plugin uses that as the image to use for the login
   screen. I would just like some help coding the settings area of the plugin. If
   you help me/give me some code that works, I would be happy to add you to the 
   list of authors for the plugin. Many Thanks, William

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/plugin-code-question/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-code-question/page/2/?output_format=md)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837934)
 * You don’t need to change any code in that file. The log oon the login page is
   set using CSS only. If you add a new CSS rule for that element you’ll be able
   to over-ride that logo display and show the one that you want.
 * To show you, this is what’s ther now…
 *     ```
       .login h1 a {
         background-image: none, url("../images/wordpress-logo.svg?ver=20131107");
         ...
       }
       ```
   
 * So, target `.login h1 a` in your CSS and you’ll be able to change that to what
   ever you want to.
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837936)
 * Ok, thanks, i was unsure how to make code work after having changing options 
   in the settings. Do you have any other tips on how to add my plugin settings 
   to the side bar and how to make the code in the plugin work with the custom information
   set in the setttings?
    If you want i can add you as a contributor to my plugin.
   Thanks, William
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837939)
 * That’s all very big questions, and I think that it’s better that you’d learn 
   that for yourself. 🙂
 * I can give you osme ideas on where to look though.
 * Start off with the menus:
    [http://codex.wordpress.org/Function_Reference/add_menu_page](http://codex.wordpress.org/Function_Reference/add_menu_page)
   [http://codex.wordpress.org/Function_Reference/add_submenu_page](http://codex.wordpress.org/Function_Reference/add_submenu_page)
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837951)
 * Ok, thanks for all your help, do you want to be added a a contribute for the 
   plugin?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837952)
 * Thanks for the offer, but that’s not necessary. If I actually did something then
   maybe, but for the help of giving you a few pointers, no I don’t think that I’d
   deserve it for that. 🙂
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837974)
 * I have another question. After some very hard work and coding i have some problems
   with adding a settings tab on the wordpress sidebar.
    For some reason the menu
   is added fine, but no subpages appear. The image is broken and when i click on
   the menu it comes up with a 404 error. Here is the code for the menu and subpages:
   add_action( ‘admin_menu’, ‘register_my_custom_menu_page’ );
 * function register_my_custom_menu_page(){
    add_menu_page( ‘custom menu title’,‘
   Williams Custom WP Login Plugin’, ‘manage_options’, ‘/public_html/dj-party-planner.
   com/wp-content/plugins/williams-custom-wp-login-plugin/settings-page.php’, ”,
   plugins_url( ‘/public_html/dj-party-planner.com/wp-content/plugins/williams-custom-
   wp-login-plugin/logo.png’ ), 6 ); }
 * add_action(‘admin_menu’, ‘register_my_custom_submenu_page’);
 * function register_my_custom_submenu_page() {
 * add_submenu_page(
    null //or ‘options.php’ , ‘My Custom Submenu Page’ , ‘My Custom
   Submenu Page’ , ‘manage_options’ , ‘my-custom-submenu-page’ , ‘my_custom_submenu_page_callback’);
 * }
 * Here is the code for the settings page i’m trying to get to work.
    <?php echo“
   Admin Page Test”; ?>
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837975)
 * You’ve missed this important note ofr `add_submenu-apge(0`…
 * > Use NULL or set to ‘options.php’ if you want to create a page that doesn’t 
   > appear in any menu (see example below).
 * So, when you use NULL there, it doesn’t add the sub-menu page to anything at 
   all.
    1. You also don’t need two separate functions to do this. Keep it as one, and it
       will simplfy your life a whole lot.
    2. You’ve also got the parameters around the wrong way, so I’m amazed that anything
       shows up at all!
    3. You have to add in the function name for these to display anything.
    4. Be careful when using a value for `$position` as you can’t guarantee that another
       plugin won’t over-write your position, and will remove your page/pages from 
       the menu.
    5. And, as a final note, _don’t ever use hard-coded file paths anywhere_. These
       change every time that your plugin is installed somewhere, so you can never 
       rely on these being the same anywhere.
 *     ```
       function register_my_custom_menu(){
           add_menu_page( 'Custom WP Login', 'Williams Custom WP Login Plugin', 'manage_options', 'custom_login', 'my_custom_menu_page_callback', plugins_url( 'logo.png', __FILE__ ));
           add_submenu_page( 'custom_login', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'custom_login_subpage', 'my_custom_submenu_page_callback');
       }
   
       add_action( 'admin_menu', 'register_my_custom_menu' );
       ```
   
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837976)
 * Ok, i will use your wise information and try it out 🙂
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837977)
 * Hmm, when i remove ‘null or ‘Options.php’ just breaks my site
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837978)
 * The example that I gave shows you what you need to have there. It needs to be
   the page slug of the main menu page that you’re trying to add it to.
 * Follow the code that I gave you above and it will work. I have tested it, and
   it adds the menus in exactly as you’re looking for 🙂
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837979)
 * Very happy for your help, just got a callback error on the page which needs tiding
   up.
    Warning: call_user_func_array() expects parameter 1 to be a valid callback,
   function ‘my_custom_submenu_page_callback’ not found or invalid function name
   in /home2/greennin/public_html/dj-party-planner.com/wp-includes/plugin.php on
   line 470
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837980)
 * That’s because you need to create teh functions to display the content for the
   admin pages that the menus link to.
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837981)
 * ? Sorry for being so incompetent. But i really don’t know what your talking about.
   example code?
 *  Thread Starter [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * (@dpskipper)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837984)
 * Any way to add CSS classes as the image on the sidebar?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years ago](https://wordpress.org/support/topic/plugin-code-question/#post-4837986)
 *     ```
       function register_my_custom_menu(){
           add_menu_page( 'Custom WP Login', 'Williams Custom WP Login Plugin', 'manage_options', 'custom_login', 'my_custom_menu_page_callback', plugins_url( 'logo.png', __FILE__ ));
           add_submenu_page( 'custom_login', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'custom_login_subpage', 'my_custom_submenu_page_callback');
       }
   
       add_action( 'admin_menu', 'register_my_custom_menu' );
   
       function my_custom_menu_page_callback(  ) [
           echo '<p>Main custom page</p>';
       }
   
       function my_custom_submenu_page_callback(  ) [
           echo '<p>Sub custom page</p>';
       }
       ```
   

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/plugin-code-question/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-code-question/page/2/?output_format=md)

The topic ‘Plugin Code Question’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 26 replies
 * 2 participants
 * Last reply from: [dpskipper](https://wordpress.org/support/users/dpskipper/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/plugin-code-question/page/2/#post-4838100)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
