Custom row action on custom posts list page causes a wp_die?
Found the issue. I have used action as a url arg, which WP uses for all its actions such as approve_comment, trash_post etc. Changed it to a custom word and my code worked like a charm!
Found the issue. I have used action as a url arg, which WP uses for all its actions such as approve_comment, trash_post etc. Changed it to a custom word and my code worked like a charm!
In general change the filter priority in your code snippet so it runs after the plugin has modified the row action, e.g. 99 or later and check out the $actions with e.g. print_r( $actions ); on your test install to find the key or search the plugin code for page_row_actions. In some cases one should … Read more
Apparently the right way to do this is to get the suffix returned by your custom page that normally displays the table and use it to hook into the page load before any admin content is rendered. add_action(‘admin_menu’, function() { $page_hook_suffix = add_submenu_page( # or related function … function() { # content of table page … Read more
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
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
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
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
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
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
Remove bulk option row