Change WordPress user roles and capabilities Forums Restrict or Permit access inside WordPress – how to Unwanted dashboard redirect when 'settings-updated' is present

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #3645
    freeaanzee
    Participant

    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):

    screenshot

    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

    #3650
    Vladimir
    Keymaster

    Hi 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.

    #3656
    freeaanzee
    Participant

    Hi,

    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.

    #3662
    Vladimir
    Keymaster

    Hi 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.

    #3676
    freeaanzee
    Participant

    Sorry 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.

    #3679
    Vladimir
    Keymaster

    Hi 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.

    #3680
    freeaanzee
    Participant

    Thanks Vladimir, works like a charm!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.