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
- How to customize WP_Error (REST JWT authentication plugin) [closed]
- Should all plugins be encapsulated in a Class?
- PHP code on Visual Composer Plugin
- How can I log a user out of WordPress before the page loads?
- How to find out if option exists but is empty?
- Thumb rating for wordpress – top user
- Errors while using ajax from external wordpress page
- Setting up widgets in wordpress with a unique ID for the after_title argument
- post expire after x days
- How to add inline css/js inside a shortcode
- allow arabic letters when register new account
- How to get all events from ‘All in one Events calender’ plugin in JSON format?
- How do you remove plugin edit option?
- Make specific products accessible only to a user role in WooCommerce
- Where should I save an API key of my user when installing my plugin?
- Accessing post’s meta data based on user’s click of a post
- Custom form action to handle data inside a plugin
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- WP Post Template – Templates in own folder
- Override Plugin Script Fucnction in WordPress
- Shrink down register_settings on Settings API
- Parse error: syntax error, unexpected ‘new’ (T_NEW) in /misc/41/000/204/381/9/user/web/ragami.net/wp-settings.php on line 219
- How to call WordPress function other files
- Ajax call returning 0
- Some code in shortcode function being ignored
- Subdomains with almost the same content
- Is there a way to figure out which action/filter invoked a function?
- publish_post action doesn’t work
- Duplicate results are displayed in a custom plugin [closed]
- php code crashes site – possible syntax error
- Help with WP Business Directory Manager Plugin?
- New bulk action to resend welcome emails
- I receive taxonomy id
- Is there a way to convert shortcodes to html content?
- Loop in elementor custom widget not working
- Change text string in a plugin
- get_users(); Is an Undefined Function When Used in Cron Job
- the_content() printing DOCTYPE, and tags in the middle of page
- How to change WooCommece variation data programmtically [closed]
- How to include files relative to a file’s directory
- .php file for woocommerce edit category? [closed]
- dynamically create callback functions inside a for loop
- WordPress truncate posts question (plugin related)
- Different registration form for different roles
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- How do I display PHP file contents on front end of WordPress?
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- Get Shortcode output to database for static post_content
- SimpleXML is not working with xml response from external api
- strtotime not working
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- How To Toggle User_Meta in frontend in a form using PHP
- Change Woo Custom Endpoint Titles from a Plugin
- WPML – Hook when language is switched (change user language)
- Use action, filter, or hook to append HTML to WordPress plugin function
- No result after wpdb->insert
- Speeding up WordPress on a Local Network
- How can I store user preferences in WordPress and retreive them later?
- Change hook to add_action in a plugin class
- How to get bulk actions handler to display simple “Hello World”?
- Cannot pass variable to page definition
- how change my menu on submenu
- Plugin debugging with errors in activation routine
- Number format in thousands on highcharts in wpdatatable plugin
- How do I change tab url
- Things that saved lose when logout
- How to speed up installing plugins and upgrading WordPress
- W3 Total Cache Can’t Really Detect Things
- PHP and Jquery pass value from form. Update function on DataBase
- How do I add php to all links automatically?
- Plugin use of ajax/jquery depending dropdown
- WordPress portfolio pagination on home page
- Need help with wordpress audio preload
- Allow direct access to files/folders within WordPress to replace wp-admin
- is_singular() in mu-plugins not working
- Error 400 Invalid “products[1].productId” Kinguin [closed]
- I want to move the one click accesbility button on bottom of my website screen,
- WordPress : how to create onglet and remove it when only one
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1