Giter VIP home page Giter VIP logo

Comments (8)

NateWr avatar NateWr commented on September 12, 2024 1

I'm reopening this because I think Editors should be allowed to manage the Business Profile options by default. The manage_options capability should be changed to edit_posts.

from business-profile.

lmartins avatar lmartins commented on September 12, 2024

Would a filter in https://github.com/NateWr/business-profile/blob/master/includes/Settings.class.php#L88 allow for this to happen?

from business-profile.

NateWr avatar NateWr commented on September 12, 2024

The capability is defined in the big settings object here, which is filtered here. So you could do something like this:

$sap = apply_filters( 'bpfwp_settings_page', $sap );

add_filter( 'bpfwp_settings_page', 'yourcustom_settings' );
function yourcustom_settings( $sap ) {

    // Inspect the $sap object here. The capability will be somewhere there.
    // Just modify it to the cap you'd prefer and then return it.
    //
    // $sap->page->wherever->i->cant->remember['capability'] = 'edit_posts';

    return $sap;
}

from business-profile.

NateWr avatar NateWr commented on September 12, 2024

Yeah, that whole big $sap is filtered. You'll need to dig in to figure out precisely where the cap gets stored, though.

from business-profile.

lmartins avatar lmartins commented on September 12, 2024

I've tried with the following:

$sap = apply_filters( 'bpfwp_settings_page', $sap );

add_filter( 'bpfwp_settings_page', 'yourcustom_settings' );
function yourcustom_settings( $sap ) {

    $sap->pages['bpfwp-settings']->capability = 'edit_theme_options';

    return $sap;
}

This does make the option available to non-admin users, but when I try to save any changes I get a screen saying "Cheatin’ uh?". Is this to be expected?

from business-profile.

NateWr avatar NateWr commented on September 12, 2024

Hmm, that does sound familiar. It's probably something internal to the simple-admin-pages lib.

Yeah, it looks like I fixed a problem like this back in December. It looks like Business Profile is using the latest version of that lib, so it should work.

Sorry, I don't have time to look into this further right now, as I'm coming up on a big deadline. But in theory it ought to work. Have you tried some other caps? Maybe it has to do with the distinction between meta caps and individual caps....

from business-profile.

NateWr avatar NateWr commented on September 12, 2024

Oh, the obvious thing to check is to make sure you're hooked in really early. The lib actually kicks in registers the page pretty early (admin_init I think), so make sure you're jumping in early.

Also, you can get rid of this line as it's not needed:

$sap = apply_filters( 'bpfwp_settings_page', $sap );

from business-profile.

NateWr avatar NateWr commented on September 12, 2024

Were you ever able to solve this problem? I tracked down the source of the issue with the Simple Admin Pages library and fixed it there. I've updated the library in the plugin and the fix should go out with the next update -- likely tonight or tomorrow.

Once that fix goes out, you should be able to use code like this to edit the capability, as long as it's executed before admin_init:

add_filter( 'bpfwp_settings_page', 'bp_allow_editor_access' );
function bp_allow_editor_access( $sap ) {

        $sap->pages['bpfwp-settings']->capability = 'edit_pages';

        return $sap;
}

from business-profile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.