WordPress show content if current user get spesific role and spesific meta value

Your question needs some additional context, but here’s a generic approach to what you’ve described. if ( is_user_logged_in() ) { $user = wp_get_current_user(); // Does user have the required role? if ( in_array( ‘some_role’, $user->roles ) && ‘some_meta_value’ == get_user_meta( $user->ID, ‘some_meta’, true ) ) { // Special content… } else { // User doesn’t … Read more

How do I set register_meta for a specific CPT?

register_post_meta has a post type parameter, or just set object_subtype to the post type. register_meta( ‘post’, ‘_duib_cl_heading’, [ ‘auth_callback’ => ‘__return_true’, ‘default’ => __( ”, ‘_duib_cl_heading’ ), ‘show_in_rest’ => true, ‘single’ => true, ‘type’ => ‘string’, ‘object_subtype’ => ‘testimonial’, ] ); Or register_post_meta( ‘testimonial’, ‘_duib_cl_heading’, [ ‘auth_callback’ => ‘__return_true’, ‘default’ => __( ”, ‘_duib_cl_heading’ ), … Read more

Store large dataset in WordPress installation temporary

Transient names are limited to 172 characters; the data held in a transient can be much, much larger. set_transient() documentation Under the hood, transients are stored in the same table as options, and some WordPress code manages their lifetimes and expiry. You should easily be able to store 1MB of data in a transient. Autoloading … Read more

Debouncing Input value with block attributes

You can use useDebounce or debounce (you also have throttle) in package @wordpress/compose I did not test the code, but something like that: import { useDebounce } ‘@wordpress/compose’; function Edit({attributes, setAttributes}) { debounced_selectTheme = useDebounce(selectTheme, milliseconds, options) <TextControl key=”music-search-input-control” label={ __( ‘Search’, ‘aawp’ ) } value = {theme} /* you have a typo in code … Read more