I am asking user few questions at the time of registration with checkboxes like

In Registration form

[] I am blah blah
[] I am blan blah
[] I am blah blah

Now user will come for approval in admin panel, in pending state.

I want to add above (Checkbox) in the listing user table. So Admin can change the data if he wants inline and as soon as click on approve data get saved in the database for that user.

This is what i have tried.

function X_member_user_table( $columns ) {
    $columns['dbem_X_member_f'] = 'Member';
    $columns['dbem_X_delegate_f'] = 'Delegate';
    $columns['dbem_X_sponsor_f'] = 'Sponsor';
    return $columns;
add_filter( 'manage_users_columns', 'X_member_user_table' );

function X_modify_user_table_row( $val, $column_name, $user_id ) {
    $column_value = get_the_author_meta($column_name,$user_id );
    //return "<input type='checkbox' name='".$column_name_.$user_id."' value='".$column_value."' id='".$column_name_.$user_id."'/>";
    //return "<input onclick='$(form).serialize();' type='checkbox' name='{$column_name}[]' id='{$column_name}_{$user_id}' class='$role'    value='{$user_id}' />";
    $checkbox = '<label class="screen-reader-text" for="cb-select-'.$column_name."_" . $user_id . '">' . '</label>'
                    . "<input type='checkbox' name='{$column_name}[]' id='user_{$column_name}_{$user_id}' class='$role' value='{$column_value}' />";
    return $checkbox;
add_filter( 'manage_users_custom_column', 'X_modify_user_table_row', 10, 3 );

I am able to get checkbox in the user table. Now the question is how to get the in $GET or $POST when user clicks on Approve link. This link is just redirecting the page and not submitting the page so i do not think it will come in post.

I have created below method to get data in GET attributes. Do I need to use jQuery to build data in it?

function X_user_row_actions($actions, $user_object){
    $current_user = wp_get_current_user();
    $u = $user_object->ID;
    if ( $current_user->ID != $user_object->ID ) {
        /*if ( in_array( 'pending', (array) $user_object->roles ) ) {
            switch ( get_option( 'type' ) ) {
                case 'admin' :*/
                    // Add "Approve" link
                    $actions['approve-X-user'] = sprintf( '<a href="%1$s">%2$s</a>',
                        add_query_arg( 'wp_http_referer',
                            urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
                            wp_nonce_url( "users.php?action=approve&amp;user=$user_object->ID&amp;dbem_X_member_f=1", 'approve-X-user' ) 
                        __( 'Approve with changes', 'theme-my-login' )
    return $actions;
    echo "<pre>";
    print "X row";
    echo "</pre>";
    return $actions;
add_filter( 'user_row_actions', 'X_user_row_actions' , 10, 2 );

However it is not working. Is there any hook to use when Approve is clicked, or change its status?

  • I want to do it without any plug-in. – Bhavin Shah Oct 11 '13 at 7:25
  • Please add that as edit. Not as comment. – kaiser Oct 12 '13 at 9:42

Yes, we need jQuery for that. The first thing is to give proper classes and ID's to the elements.

In manage_users_custom_column, add a class and a data selector to the checkbox:

"<input type='checkbox' data-approval='#approval-$user_id' class='my-class' value='{$column_value}' />"

And in user_row_actions, an ID to the <a> tag: id='approval-$user_id'.

Now, we have all the elements properties and can manipulate the URL of the Approve with changes links.

add_action( 'admin_footer-users.php', 'print_jquery_wpse_117481' );

function print_jquery_wpse_117481() 
    <script type="text/javascript">
            console.log( 'Is checked: ' + $(this).is(':checked') );
            console.log( 'This ID: ' + $(this).attr('id') );

            var a_href_approval_id = $(this).data('approval');
            var a_href_final = $( a_href_approval_id ).attr('href');
            console.log( 'Manipulate this attribute: ' + a_href_final );

Hint: use sprintf to build $checkbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.