How to secure custom endpoint for rest api in WordPress

Add permission_callback parameter and set it to whatever authentication you want to apply. So, if you want to make it accessible to a user having manage_options capability, your code should be something like this- add_action(‘rest_api_init’, function(){ register_rest_route(‘fs/v1’, ‘posts’, [ ‘methods’ => ‘GET’, ‘callback’ => ‘fs_posts’, ‘permission_callback’ => function( $request ) { return current_user_can( ‘manage_options’ ); … Read more

Using a shortcode to get User Emails by role as specified in the shortcode, need help to allow for multiple roles

If you’re trying to get users with all roles (in your example, administrator and author), your code looks like it should work. If you want users with any role (administrator or author, you’ll need to split the string in the role attribute into an array using explode(), and use the role__in array. Something like this … Read more

Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?

Yes, but you have to do it Redux- way. Subscribe to post saving action (there are separate actions for save and auto-save) and dispatch a message using dispatch function. Edit: Inside blocks, there are better hooks to use, like useSelect. But, outside the block, in general block editor environmentm you have to use subscribe. In … Read more

Custom Gutenberg block with nested InnerBlocks renderAppender not displaying add button

In gc-slider2/index.js, I removed the templateLock=”all” from the InnerBlocks, and it is now displaying the plus sign for the gc-slider-items block. <InnerBlocks template={SLIDER_TEMPLATE} allowedBlocks={ [ ] } /> Which leaves me with a different problem of two add block plus signs. See Gutenberg Innerblocks notallowedblocks on parent but allowedblock on child