Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Unwanted dashboard redirect when 'settings-updated' is present
- This topic has 6 replies, 2 voices, and was last updated 7 years, 7 months ago by Oxfam.
-
AuthorPosts
-
01/05/2017 at 19:02 #3645OxfamParticipant
Hi,
First of all: nice plugin! We use URE Pro in a multisite network to create an intermediate WooCommerce shop manager role who only has access to orders but not products or options (manage_options disabled):
There are however some options that can be set by this user role (e.g. holidays). I built a custom page for those, and lowered the required capability to alter these settings with the ‘option_page_capability_{$option_group}’ filter.
This works great (options are saved) but afterwards the local shop manager gets redirected to the dashboard, with no clue about what happened. I did some tests and this seems to be caused by the presence of the ‘settings-updated=true’ parameter in the URL that is generated by WordPress after the options have been saved.
Would it by possible to add this parameter to the ignored list? It’s a bit similar to the WooCommerce Product Search issue that was solved last year … I might dig in your code to find the list, but I imagine this might be helpful for other user too!
Greetings,
Frederik
02/05/2017 at 01:46 #3650VladimirKeymasterHi Frederick,
Thanks for the feedback. Yes, it’s possible to at URL parameters into “allowed” list.
Send me a full URL (without domain) in order I know exactly what WooCommerce option you change.02/05/2017 at 10:52 #3656OxfamParticipantHi,
Holidays aren’t in WooCommerce core so it is a custom option page: /wp-admin/admin.php?page=oxfam-options. This page can be reached by people with the local_manager capability (as defined in the add_menu_page() function) but /wp-admin/admin.php?page=oxfam-options&settings-updated=true is redirected to the dashboard.
F.
03/05/2017 at 04:12 #3662VladimirKeymasterHi Frederick,
Can you provide me a copy of this oxfam plugin for testing and selection an appropriate solution.
It’s possible to add its URL argument directly to URE Pro allowed list of URL parameters for this plugin (if this plugin quite popular) or, in other case, just setup custom filter which will add such parameter at your installation. I will show you a code sample then.04/05/2017 at 23:11 #3676OxfamParticipantSorry for the delay! This isn’t a public plugin, it’s just a page I built to set some custom WordPress options (check content here). So the latter solution seems to be the way to go :). I’d be happy to use the filter.
05/05/2017 at 03:42 #3679VladimirKeymasterHi Frederick,
You can use this code to add additional arguments to allowed list for this page:
add_filter('ure_admin_menu_access_allowed_args', 'ure_allow_args_for_oxfam_options', 10, 1); function ure_allow_args_for_oxfam_options($args) { $args['admin.php']['oxfam-options'] = array( 'page', 'settings-updated' ); return $args; }
Install it as must use plugin or add to funcitions.php file of active theme.
05/05/2017 at 07:53 #3680OxfamParticipantThanks Vladimir, works like a charm!
-
AuthorPosts
- You must be logged in to reply to this topic.