Add Slug Metabox to posts for contributors

I approached by doing the opposite with using remove_meta_box() for the Slug metabox if the user is not an administrator or contributor: add_action( ‘admin_menu’, ‘wpse_237291_remove_slug_metabox’ ); function wpse_237291_remove_slug_metabox() { $user = wp_get_current_user(); $allowed_roles = array( ‘administrator’, ‘contributor’ ); if ( !array_intersect( $allowed_roles, $user -> roles ) ) { remove_meta_box( ‘slugdiv’, ‘post’, ‘normal’ ); } }

Appending a value to metabox before and after saving

I was able to get it working by adding this… jQuery(document).ready(function($){ var custom_uploader; var currentfiles = document.getElementById(‘my_file_URL’).value; var currentID = document.getElementById(‘my_file_ID’).value; ….. var urls = selection.map( function(attachment){ return attachment.url; }); var ids = selection.map( function(attachment){ return attachment.id; }); $( ‘#my_file_URL’ ).val(urls.join(‘,’)); $( ‘#my_file_ID’ ).val(ids.join(‘,’)); if(currentfiles != ”){ $( ‘#my_file_URL’ ).val(currentfiles + “,” + urls); } … Read more

How can I filter the contents of a metafield before it’s displayed in the admin?

I have seen that CMB2 offers the possibility to create a custom escaping function with which the values are checked before they’re displayed. So I set the escape_cb parameter in the metafield this way: $cmb->add_field( array( ‘name’ => esc_html__( ‘Text Area for Code’, ‘cmb2’ ), ‘id’ => $prefix . ‘textarea_code’, ‘type’ => ‘textarea_code’, ‘sanitization_cb’ => … Read more

Using WPAlchemy metabox values in another metabox

Ok, I finally managed to solve that by myself. It is possible thanks to : Create the first field : <?php while($mb->have_fields_and_multi(‘types’)): $mb->the_group_open(); $mb->the_field(‘type’); ?> <input type=”text” id=”<?php $mb->the_name(); ?>” name=”<?php $mb->the_name(); ?>” value=”<?php $mb->the_value(); ?>” /> <a href=”#” class=”dodelete button”>Remove</a> <?php $mb->the_group_close(); endwhile; ?> <a href=”#” class=”docopy-types button” style=”float: left”>Add new</a> <a href=”#” class=”dodelete-types … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)