admin_post action not usable if admin access denied to user

What about (1) current_screen? action hook, or a condition for (2) get_current_screen() in your conditional and then calling wp_redirect? Both give you a WP_Screen object which has several parameters, including a $parent_base property that can give broader inclusion if needed, too. Here’s the property list from the codex: $action Any action associated with the screen. … Read more

Add css code in admin_enqueue_scripts

If you’re using the admin_enqueue_scripts hook, use wp_enqueue_script() to enqueue a CSS file with the styles you want to apply. If you want to output a <style></style> element use the admin_head hook to output it between the <head></head> tags: function custom_css_stuff() { ?> <style type=”text/css”> body { color: red; } </style> <?php } add_action( ‘admin_head’, … Read more

Display post meta on edit page in admin

I found the answer: add_action(‘add_meta_boxes’, ‘add_contact_form_meta_box’); function add_contact_form_meta_box() { add_meta_box(‘contact-form-meta-box-id’, ‘Submission Data’, ‘contact_form_meta_box’, ‘contact_form’, ‘normal’, ‘high’); } function contact_form_meta_box($post) { echo get_post_meta($post->ID, ‘first_name’, true); }

How can I use a variable to include a linked image?

You are most of the way there, you simply have to echo it into the include: <a href=”https://wordpress.stackexchange.com/questions/276748/<?php echo $url;?>/image.png”><img src=”https://wordpress.stackexchange.com/questions/276748/<?php echo $url;?>/image.png”></a> If you are already echoing this whole line, then you simply concatenate the variable: echo ‘<a href=”‘.$url.’/image.png”><img src=”‘.$url.’/image.png”></a>’ Do some reading on PHP “concatenation” 🙂

Add field to dashboard to update embedded URL on homepage?

Add the below code in the functions.php file and it will create a text field in the general setting options page add_action(‘admin_init’, ’embed_url_initialize’); function embed_url_initialize() { // First, we register a section. This is necessary since all future options must belong to one. add_settings_section( ‘general_settings_section’, // ID used to identify this section and with which … Read more

show different admin menu to different user roles

The menu items are bound to capabilities. A good overview can be found here. For example, if you do not have the capability edit_posts the menu item “Posts” would not show up. How are menu items bound to capabilites. Generally speaking: If you register a menu item using add_menu_page() or add_submenu_page() you have to assign … Read more