I have the same question, basically need to protect a specific URL(not a page,post,…) for specific roles to have access only but as of now that URL is not auto populating in the list as seems it’s not a page,post since created by an add-on of a plugin.
@cbfriend – URL targeting rules are planned in the Pro version already. There will also be rules for checking query args, referrer url (facebook etc) and more.
@smithjhsn – Many times this depends on the individual plugin/addon your dealing with.
If you want to tell me what plugin/content doesn’t have rules currently we can look into adding proper custom rules for that plugin.
For example, v2.1 (free) will include custom rules for WooCommerce shop & account pages/subpages. They are built based on actual WooCommerce APIs so if the urls change one day, you don’t have to correct things in every restriction/block, it will just continue to work.
If your interested in the Pro version, we are prepping v1 for launch, I’ll work to squeeze these rules in to the first release.
Final DIY based alternative, you can hack in your own custom rules: https://github.com/code-atlantic/content-control/blob/master/classes/RuleEngine/Rules.php#L200
Lots of example rules there to draw from, only thing you’d have to code yourself was the callback, which simply needs to be a function that returns true/false.
Hope that helps.
Hi Daniel,
This custom URL content is actually to restrict a page in a different language by WPML (which couldn’t be found in the page selection in Content Control). Without this feature, does it mean that it wasn’t compatible with multilingual plugin at this stage? Thanks
@cbfriend – Ok in that case I’ve been working with WPML on remapping our targeting rules so they can be applied across translations properly. This is probably the correct solution for your needs as well, though its likely a bit off so we can help you craft a custom rule in the mean time.
Your callback would be something like
function custom_rule_callback() {
return strpos( $_SERVER['REQUEST_URI'], '/url/you/want' ) !== false;
}
You would register it something like this:
add_action( 'content_control/rule_engine/register_rules', function ( $rules ) {
$rules->register_rule( [
'name' => 'custom_rule_1',
'label' => __( 'My Custom Rule', 'content-control' ),
'context' => [ 'content' ],
'callback' => 'custom_rule_callback',
] );
} );
Thanks Daniel. Sorry can I know where does this callback function goes to? Do both of this function go under a snippet php code will do? Thanks for the help!
Apologies, just realised that this plugin actually works perfectly fine with WPML. All you need is change the language to the language you want in the dashboard and then you’ll be able to find and restrict the secondary language. Great plugin!
I’m using frontend-editor-add-on-for-learnpress (see link below) and will create a url …./frontend-editor which I want to restrict only to instructors(LP role which popped up in roles of your plugin)
Thanks
https://thimpress.com/product/frontend-editor-add-on-for-learnpress/
-
This reply was modified 2 years, 7 months ago by
smithjhsn.