The preferred method of creating a settings page is to use the WordPress Settings API.
From your code example, it looks like it’s too late to remove the admin_notices
hook inside your callback in the admin_menu
hook.
You should try to move the logic from the customfunc()
callback into another callback activated from some earlier hook, for example admin_init
.
Additionally:
You are also calling the new admin menu page settings, but the user might confuse it with the existing Settings page.
The User Levels you have in one of the add_menu_page()
input parameters, are deprecated, use instead some of the Capabilites mentioned here.
So instead use for example:
add_menu_page( 'My settings', 'My settings', 'manage_options', 'custom', 'customfunc' );
Related Posts:
- How can I see all the actions attached to an “add_action” hook?
- Which hook callback has priority if both plugin and theme use the same hook?
- How to Use Parameters with a Do_Action Function Within PHP Tags
- How to stop or remove an action being called inside a function of an extended class
- Automatically add attributes to woocommerce product?
- wordpress plugin is not activating from widget
- Removing an action from wp_footer called in a class that’s inside a bigger class
- What is @Action in WordPress?
- How passing values to construct function with Actions?
- Basic function call on init failing
- Are there action hooks for comments?
- Hooking into the HTML header container
- Get post content inside plugin class method
- Ajax call to php function doesn’t work PHP code
- Creating Admin Submenu Page via Class Method
- plugins_loaded action is not working properly
- Plugin Hook: Get posts
- add_action() not working for admin
- wp_head filter not executed inside custom class
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- How to customize WP_Error (REST JWT authentication plugin) [closed]
- Pass a php string to a javascript variable
- get shortcode value
- How to get number of Affected rows from wordpress dbDelta() function
- Show price with Geo IP location
- Where to hook my plugin’s action
- WordPress Ajax Callback
- Add category to body class
- The called constructor method for WP_Widget in GFWidget is deprecated since version 4.3.0! Use
- Plugin Development sqlite or WordPress’ database
- How to review WordPress website php version compatibility?
- printf – problem to understand code
- Custom Post Type Plugin not loading category template and loading 404 instead
- Sending email from inside a plugin using PHP PEAR
- Overwrite or Replace code in WP_Footer
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- Storing Options in a Shortcode
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- How to generate video out of images via WordPress plugin
- How can I get WordPress to save comments in markdown format?
- add_query_arg not working
- problems with wordpress and php version 5.3.3-1
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Open Post Thumbnail in New Child Theme File in WordPress
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- Where should I save an API key of my user when installing my plugin?
- Prevent a plugin from being automatically activated
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Accessing post’s meta data based on user’s click of a post
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- Preferred way of cacheing a value in php
- Redirecting to home page after login as custom role WordPress
- WordPress Redirect Not Working – AJAX Callback Response Not Picked Up
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- Add Product Subtitle to Woocommerce Product Page
- Self deactivate plugins after an action occurs
- wp_redirect() not working in Insert PHP plugin in WordPress
- Download any file after submitting a form [closed]
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- woocommerce 3.2.1 not sending order notification emails
- WordPress takes too much time (100 seconds) to load – Front end and back end
- WordPress filter that hook after each action/filter hook
- WordPress on AWS with ELB
- Saving changes in wp_editor
- Executing my function once on a specific time
- Set Post Format if find a string in title or post content
- Display data on Word Press site posts and pages from mysql table
- Notepad sticky plugin
- Output array into one table cell
- WooCommerce Custom Product to checkout
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- Get posts from WP_Query and format them on admin_head
- WP Post Template – Templates in own folder
- Any hook for pre-plugin-update -either bulk or single plugin update
- Apple push notification doesn’t work
- Avoid class name collision when using third party libraries in plugins?
- Adding an Options Page to a Plugin
- how to change the verification url of pie register plugin of wordpress?
- How do I “get the next 10 posts after post_id == x”?
- How to access data in wordpress database externally using php
- Insert new user with form submit ‘init’ hook
- How make a php script run only with wp-cron
- How to add equivalent of php include to one page (as plugin?)
- Theme my Login plugin, how to update fields
- Edit Yoast SEO breadcrumbs output [closed]
- CSS from textarea in options page to frontend what to do
- How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
- Adding a slider captcha to the comment system
- Date calculations from 2 custom fields
- How do I pass a post ID to the page URL?