Disable “quick edit” for specific pages in functions.php

To reference the post ID you need the post object itself. <?php // Increase the number of arguments passed. add_filter( ‘page_row_actions’, ‘remove_page_row_actions’, 10, 2 ); // 2, not 1 // pass $post object as second argument. function remove_page_row_actions( $actions, $post ) { $post_types_affected = array(‘page’); $post_ids_affected = array( 111, 222 ); if ( in_array( $post->post_type, … Read more

Get user ID when action row link is clicked

I am passing the user ID as user via the link so its show in my custom list table url. For example, admin.php?page=history_logger&user=3 The user ID is in the query variable. You can access it using a PHP global variable. $_GET[‘user’] $user_id = $_GET[‘user’]; Do not assume that this request (link) came from the Users … Read more

Init action and refresh page after form action

From the documentation: https://developer.wordpress.org/reference/hooks/init/ add_action( ‘init’, ‘process_post’ ); function process_post() { if( isset( $_POST[‘unique_hidden_field’] ) ) { // process $_POST data here } } In your example, perhaps having two different add_action is causing problems and burying your function where it’s not firing during init I’m going to test a similar solution and see what … Read more

Add and Remove Row Actions in an Existing WP_List_Table

As for the user rows in the Users list table (at wp-admin/users.php), you would use the user_row_actions hook like so: add_filter( ‘user_row_actions’, ‘my_user_row_actions’, 10, 2 ); function my_user_row_actions( $actions, $user_object ) { // Remove the Edit action. unset( $actions[‘edit’] ); // Add your custom action. $actions[‘my_action’] = ‘<a href=”<action URL>”>Action</a>’; return $actions; } The other … Read more

Delete data from database using row action

The “admin_action_{$_REQUEST[‘action’]}” hook does not pass any arguments. You would need to get the article_id from the $_REQUEST array. There are also a few other concerns such as: You’re not assigning an action when you call wp_create_nonce(). As Mafnah suggets in their ansewr, you should use $wpdb::delete() as a shortcut for using $wpdb::prepare(). Here’s how … Read more

Rename a row action label

Put this in your functions.php file: function rename_delete_action($actions) { // replace Delete Permanently text, if present // (i.e., if the current user is able to delete posts) if (isset($actions[‘delete’])) $actions[‘delete’] = preg_replace(‘@>(.*)<@’, ‘>WHATEVER<‘, $actions[‘delete’]); return $actions; } // function rename_delete_action if (‘edit.php’ === $GLOBALS[‘pagenow’]) { // add filter for Edit pages only add_filter(‘post_row_actions’, ‘rename_delete_action’); add_filter(‘page_row_actions’, … Read more