How to add wordpress username after url?

You can do <?php if( get_current_user_id() ): // check if user is loggedin $current_user = wp_get_current_user(); //get user ?> <a href=”https://direktoriku.com/shopping/?user=<?php echo $current_user->user_login;?> <button>Click me</button> </a> <?php endif;?>

How to restrict specific post types from being read or added by specific user roles (eg. author)?

For the solution to your question, In the register_post_type arguments, use the capability_type parameter & then grant the specific capabilities to the users. For instance, if you set ‘capability_type’ => ‘supplier’, grant the edit_supplier capability to all administrators only More Details capabilities takes an array of the capabilities in the format ‘edit_post’ => ‘edit_supplier’ This … Read more

Getting the Current User

Call the function get_currentuserinfo() on the next line after declaring the global variable $current_user What is the difference between wp_get_current_user() and get_currentuserinfo()? Below is a snippet: function wp_get_current_user() { global $current_user; get_currentuserinfo(); return $current_user; } I think the source code answers your first two questions, right? Remember that wp_get_current_user() is defined in wp-includes/pluggable.php so it … Read more

Make certain pages uneditable by editors?

You can try the map_meta_cap filter: /** * Uneditable posts/pages for editors */ add_filter( ‘map_meta_cap’, function ( $caps, $cap, $user_id, $args ) { // Edit to your needs: $post_ids = [123, 234, 345, 456]; // Uneditable posts $role=”editor”; // Uneditable by this user role // Make given posts uneditable for the above user role: if … Read more

Mass delete spam accounts

Yes. There are a variety of ways to do this, primarily, we’ll need to tackle the wp_delete_user() function. Your first task, and the tricky one, is to identity which accounts are spam, and which are real. This can be quite an adventure if your site gains new users regularly. With the following example, we target … Read more

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