0

Hello guys I have a question to make a link below user list. Please check myspace edit link from picture.enter image description here the below code used for this link:

function cgc_ub_action_links($actions, $user_object) {
        $actions\['edit_badges'\] = "<a class='cgc_ub_edit_badges' href='site_url?page_id=13&um_user=$user_id&profiletab=main&um_action=edit" . admin_url( "users.php?page=cgc-badges&action=cgc_edit_badges&amp;user=$user_object->ID") . "'>" . __( 'Edit MySpace', 'cgc_ub' ) . "</a>";
        return $actions;
    }
    add_filter('user_row_actions', 'cgc_ub_action_links', 10, 2);

please check "href=" i want to make a link here when admin click this link he will be transfer to a new link like https://localhost/sitename/page_id=13&um_user=$12&profiletab=main&um_action=edit

How can i do that please help me. thanks in advance

1

I am assuming the \ are not part of your code, but if they are then those need to be removed. You also are trying to use $user_id without ever declaring it.

Here is how I would write the function:

function cgc_ub_action_links( $actions, $user_object ) {

    $url = add_query_arg( array(
        'page_id'    => 13,
        'um_user'    => $user_object->ID,
        'profiletab' => 'main',
        'um_action'  => 'edit',
    ), site_url() );

    $actions['edit_badges'] = "<a class='cgc_ub_edit_badges' href='" . esc_url( $url ) . "'>" . __( 'Edit MySpace', 'cgc_ub' ) . "</a>";

    return $actions;
}
add_filter( 'user_row_actions', 'cgc_ub_action_links', 10, 2 );

I have fixed the misuse of using $user_id and replaced it with the passed in user ID by using $user_object->ID. Since you are trying to link to a front-end page and not an admin page then it makes more sense to just add the query args to the main site URL.

I hope this helps!

  • thanks for your answer i already found my solution.my code is function myspace_edit_page($actions, $user_object) { // print_r($user_object);die(); $actions['edit_badges'] = "<a class='cgc_ub_edit_badges' href='localhost/ebootcamp/user/$user_object->ID/…'>" . __( 'Edit MySpace', 'cgc_ub' ) . "</a>"; return $actions; } add_filter('user_row_actions', 'myspace_edit_page', 10, 2); – Arman Jun 26 '18 at 7:20
  • have another question can you please tell me how can i add a form below the user table. form will be short code – Arman Jun 26 '18 at 7:22

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.