Is there an option to execute javascript file only on plugin activation

Here is the solution: register_activation_hook( __FILE__, ‘rest_api_hook’ ); /** * Runs only when the plugin is activated. */ function rest_api_hook() { /* Create data */ set_transient( ‘rest_api’, true, 5 ); } /* Add notice */ add_action( ‘admin_notices’, ‘rest_api_hook_exec’ ); /** * Rest API Notice on Activation. */ function rest_api_hook_exec() { /* Check transient, if is … Read more

500 Error, Get custom field and returning it

500 error or internal server error is probably caused by a PHP error. By enabling WordPress debug, you’ll easily find where the problem is. You can follow the instructions here https://wordpress.org/support/article/debugging-in-wordpress/#wp_debug_log From your code, it’s easy, you’re missing a semi-column before the closing curly bracket.

Add my footer menu to the header

You have to add more links in your header menu like: <div class=”menu”> <a class=”btn”>Kategorien <span class=”icon icon-angle-down”></span></a> <ul class=”actions”><!–THIS IS YOUR CATEGORIES SUBMENU–> <li class=”cat-item cat-item-17″> <a href=”https://duvacon.de/category/action/” data-hasqtip=”13″ oldtitle=”Action” title=”” aria-describedby=”qtip-13″>Action</a> </li> </ul> <!– NEW ITEMS –> <a href=”%LINKTOCONTACT%” class=”btn”>Contact</a> <a href=”%LINKTOCHAT%” class=”btn”>Chat</a> </div> I don’t know if you are adding in the … Read more

How do I get the value of a current user’s custom field?

Add this to the frontend and you should be able to adjust it to display whatever field you’ve added. $user_info = get_userdata(get_current_user_id()); echo ‘Username: ‘ . $user_info->user_login . “<br>”; echo ‘User roles: ‘ . implode(‘, ‘, $user_info->roles) . “<br>”; echo ‘User ID: ‘ . $user_info->ID . “<br>”; echo ‘User Agent Department: ‘ . $user_info->agentdept . … Read more

Used a code to revoke some dashboard menus for my contributors but for some reason it’s revoked me access to the editor [closed]

Issue #1 This line of code define( ‘DISALLOW_FILE_EDIT’, true); does not go into functions.php. It should be removed from function.php and put in your config file, wp-config.php in the root of your WP install. Here is more info on what DISALLOW_FILE_EDIT does. Issue #2 You are removing the menu items for admins. if(current_user_can( ‘administrator’ )){ … Read more

Before & After Content – After Content directly below Before Content when using require_once

If the file you want to attach (eg. footer-registered-include.php) print/display some text, this text will be displayed in the time you include the file. To assign to the variable the content displayed by the included file you should: turn on output buffering include file contents of the output buffer and end output buffering function wpdev_before_after($content) … Read more