I want to add a new wordpress page - php

Happy new year to everyone. I added a new link in my wordpress. The url is wp-admin/users.php?page=business&user_id=2 but when I access the page is says You do not have sufficient permissions to access this page. I know that the page is not created yet business How will I create new page so that I can work on page=business?

It is really that easy please add the following code. Let me know if you require more help.
add_action('admin_menu', 'adminMenus');
function adminMenus(){
add_submenu_page( 'users.php', 'Business Page Title', 'My Business Menu', 'manage_options', 'business', 'businessPageFunction');
}
function businessPageFunction(){
echo "Meow...";
}
For more information View Function Reference/add submenu page and Plugin API/Action Reference/admin menu

Related

Custom Admin page using add_menu_page

I have developed a plugin to write my own customized functions and its already activated. I want to add 1 page on the admin dashboard and using below code but it doesn't seem to be working
add_action('admin_menu', 'addAdminPage');
function addAdminPage() {
add_menu_page('Status Page', 'Status Menu', 'manage_options', '__FILE__', 'AdminPage', 'dashicons-wordpress',90);
}
function AdminPage() {
echo 'Hello';
}
You say it's not working but you haven't told us what the error is. Regardless, if you use this, it should work:
add_action( 'admin_menu', 'addAdminPage' );
function addAdminPage(){
add_menu_page(
__( 'Status Page', 'yourplugintextdomain' ),
'Status Menu',
'manage_options',
'statuspage',
'AdminPage',
'dashicons-wordpress',
90
);
}
function AdminPage(){
esc_html_e( 'Hello', 'yourplugintextdomain' );
}
You shouldn't be attempting to use the ( __FILE__ ) as the slug, so I just made it statuspage. Whenever you're writing custom functionality like this, try to prefix everything with something that relates it back to your plugin. Like: lrnr_statuspage and name your functions stuff like lrnr_AdminPage that way you reduce the risk of running into conflicts. Include your plugin or theme's text domain as well to make what you're building translation ready. It's just good practice.
Update/Correction:
I had the function name incorrect. It will work now.
Here is it running on a site I'm currently developing, I just added the above block of code to the bottom of my functions.php and added your username to the 'Hello' message.

WordPress add_menu_page not showing in backend

I am trying to create a custom plugin using the code below but the tab/link to the page is not appearing in the WordPress Dashboard and I'm not sure what I'm doing wrong. My company-admin.php file is located in my plugins folder inside a folder called company-admin. The file permissions for the php file are 644 incase that is relevant. Can you help?
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_menu_page(
'Company Admin',
'Company Admin',
'manage_options',
'company-admin/company-admin.php',
'',
'',
6
);
}
I'm unsure if this is the correct way to navigate to my plugin but I used this link, correct me if its the wrong link;
https://mywebpage.uk/wp-admin/admin.php?page=company-admin%2Fcompany-admin.php
And what I get is the following error;
Sorry, you are not allowed to access this page.
Query Monitor
The message above was triggered by Core.
Call stack:
wp_die()
wp-admin/includes/menu.php:348
the permission file in wordpress must be 755 for work correctly.
For develop a plugin follow the wordpress official guide https://developer.wordpress.org/plugins/intro/
Let me know.
Try to add more code to your path. Instead of 'company-admin/company-admin.php', paste 'your_plagin_folder/company-admin/company-admin.php',
Edited
But more cleanest is using that way:
function wpdocs_register_my_custom_menu_page(){
add_menu_page(
'Custom Menu Title',
'custom menu',
'manage_options',
'custompage',
'my_custom_menu_page',
'',
6
);
}
add_action( 'admin_menu', 'wpdocs_register_my_custom_menu_page' );
/**
* Display a custom menu page
*/
function my_custom_menu_page(){
//print all what you need or include any pages
include_once plugins_url('company-admin/company-admin.php', __FILE__);
}

Menu is not showing in admin panel

I try to make my own theme in wordpress. Stucked a problem: i can't see menu button in admin panel. I've registered menu in functions.php of my theme
<?php
register_nav_menu( 'menu', 'Menu on the main page' );
?>
But there is no menu button appear in admin panel - appereance. I did all that was recommended on youtube video (https://youtu.be/I0zu6Dc3JDI?t=95). Nothing. Please help =) I have last version of Wordpress.
You was half way there, you had the right idea for registering the menu however you missed out telling WordPress to run your register menu command.
What you need to do is wrap it in a function and call the function on 'init' which is the initialisation of the admin area (one of many WordPress hooks), see below:
function register_child_menus() {
register_nav_menus(
array(
'my-menu' => __( 'My Menu' )
)
);
} add_action( 'init', 'register_child_menus' );

Wordpress plugin pages

I'm not sure how to ask this so I'll explain my problem first. I have a plugin for Wordpress that updates a calendar and some databases that have multiple id's. So I have a hook for a page "editrental.php" which works fine but then when I click on a link for a certain item and goes to something like this
"editrental.php?id=3828" it won't let the page show. I'm guessing it has something to do with the way i set up the hook which is like this
add_submenu_page(null,'Wasatch Front Waste Calander Manage Editrental',
'WFWRD Calendar Manage Editrental', 'manage_options', 'trailer-scheduler-
editrental', 'trailer_admin_editrental');
Any ideas on how to set this up correctly or links to send me in the right direction? Thanks everybody.
Try using this
add_submenu_page(
'edit.php?post_type=POST-TYPE-NAME', //under which post/custom post the submenu should appear
__('Submenu Title','menu-test'),
__('Submenu Title','menu-test'),
'manage_options',
'custom-admin-page',
array($this, 'function-name') //where the functionality works for the submmenu
);
// Add to admin_menu function
$page = add_submenu_page( 'edit.php?post_type=theme', __('Theme Page Options'), __('Theme Menu Options'), 'edit_themes', 'theme_options', theme_options);
function theme_options() {
// Render our theme options page here ...
}
So to fix this all I ended up doing was switching "editrental.php?id=3828" with "editrental.php&id=3828". For some reason it wasn't excepting the ? but it did except the &.

Wordpress Issue Create Menu Option

I have created a Custom Setting API for web developing for a client. I was just creating first menu option on the WP dashboard.
But when I send file I get this error message saying -->
:call_user_func_array() expects parameter 1 to be a valid callback, function ' allb_admin_page' not found or invalid function name in
function allb_admin_page() {
add_menu_page( ' ALLB Theme Options', 'ALLB', 'manage_options', 'a-legacy-left-behind', 'allb_theme_create_page', 110);
}
add_action( 'admin_menu', ' allb_admin_page' );
function allb_theme_create_page() {
// genration of our admin page
}
I was thinking this may be new update or this function that i am using might be removed from WordPress or i am doing something wrong please explain.
Can anyone help with this quick issue having on word press, please?
Thank you,
Happy New Years!!!
You need to remove the space:
add_action('admin_menu', 'allb_admin_page');
Here is the answer..
Please try it once, Just copy and past this code..
function allb_admin_page() {
add_menu_page('ALLB Theme Options', 'ALLB', 'manage_options', 'a-legacy-left-behind', 'allb_theme_create_page', 110);
}
add_action('admin_menu','allb_admin_page');
function allb_theme_create_page() {
// genration of our admin page
}
I hope it'll help to you..

Categories