justintadlock / members

Members WordPress plugin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gutenberg: Show/hide blocks

justintadlock opened this issue · comments

Now that Gutenberg and WP 5.0 are around the corner, it's time to give some serious thought about integration. I'm not sure if this will be directly in Members or an add-on plugin, but I wanted to get the ball rolling on the idea.

Gutenberg is a block-based system. Right now, the primary focus is the editor. However, blocks will be replacing many things in the future.

Each block in Gutenberg can have its own settings. The idea here is for Members to "hook" into each block's settings and add its own permissions settings. That way, users can control this on a per-block basis.

This would be a combination of the following things:

  • The current Content Permissions meta box.
  • The [members_access] shortcode.
  • The [members_logged_in] shortcode.
  • And, potentially other ideas for hiding/showing the block.

Permissions could be based on:

  • Role.
  • Capability.
  • User.
  • Logged-in status.
  • Maybe even user some user meta key/value.

Each block should be able to show either:

  • The block if the user has permission.
  • Nothing at all.
  • A default error message.
  • A custom error message.

This new system wouldn't completely replace the old stuff. I still think it's smart to have post/page-level access, so the Content Permissions wouldn't be going anywhere. And, shortcodes will always be available for back-compat anyway.

Rather, this system is going to be the future. Block-based permissions are where it's at.

Where to start?

I have minimal experience coding for Gutenberg at this point. And, I'm not even sure that it's possible to hook into other blocks' settings.

So, that's where we begin.

Hey Justin! This is a good idea to start thinking about this, so thanks for that! I've got a little bit of Gutenberg experience and would love to help with this but time is a bit short currently. I'll make sure to watch this and see if I can add input or help hack on some things if I can find some more time.

@justintadlock and @JulienMelissas you can check this plugin of mine : https://wordpress.org/plugins/block-options/ which already has the option to manage block visibility. I've also added Display Logic for custom restriction :) I hope you'll love it!

Cheers!

Any updates on adding role based block visibility?

It's been a long time coming, but I'm finally releasing this today. Woo-hoo!

https://themehybrid.com/plugins/members-block-permissions

I'll have an official announcement up on the Theme Hybrid blog today.