Ad 468 X 60

Wednesday, 28 May 2014

Widgets

Add or edit custom link in wp users list in wordpress admin

To enhance the knowledge in WordPress , i am going to write new post for add new custom link in WordPress " User list " or  we can modify exist link and list name  also ..See below the screenshot.

Now question is what should i do to do it??
Yeah its vary to implement  this functionality  here i share a piece of code .to tetsing please copy and paste it into your "Theme Function.php" and save and then run it. this code will edit the existing link.

function my_custom_action_link($actions, $user_object) {
global $wp_roles;
$userRole = new WP_User( $user_object->ID );
$userRole->roles[0];
if($userRole->roles[0]=="administrator" || $userRole->roles[0]=="editor" || $userRole->roles[0]=="university_admin")
{
$profileurl= admin_url("user-edit.php?user_id=$user_object->ID&wp_http_referer=%2Fwordpress%2Fwp-admin%2Fusers.php"); 
}
else
{
$profileurl= get_permalink( get_page_by_path( 'Subscriber Profile Page' ) )."?user=$user_object->ID"; 
}

$actions['edit'] = "<a class='cgc_ub_edit_badges' href='" .$profileurl. "'>" . __( 'Edit', 'cgc_ub' ) . "</a>";
return $actions;

}
// this filter change the link of users edit row in wp admin
add_filter('user_row_actions', 'my_custom_action_link', 10, 2);
// this filter change the link of users edit row in wp admin 


Now if you want Add new link in user row action please copy and paste in your function.php \

function add_new_link($actions, $user_object) {
    $actions['custom_link'] = "<a class='your_class' href='" . admin_url( "users.php?user=$user_object->ID") . "'>" . __( 'Custom Link', 'cgc_ub' ) . "</a>";
    return $actions;
// admin_url( "users.php?user=$user_object->ID") where this will generate admin users view url you can put site_url() for example

}
add_filter('user_row_actions', 'add_new_link', 10, 2); 



If you have any query for this post then please do comment here

SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati

5 comments:

  1. It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks.
    s2Member coupon code

    ReplyDelete
  2. Hi do you know what class is available to change color link action?

    basically i want to add more action links in at http://www.adesignideas.com/ but with different color to make it easier when look

    ReplyDelete
  3. Hello i have a little problem. I would like this link to point to a function in my plugin that performs an action with the user id how can i do that. i already know how to display the id of the user on the wp-admin users list

    ReplyDelete
  4. Have you recently received less than satisfactory service from a company that has made you want to complain about it? You certainly need to bring this problem to their attention. The issue is whether you need to write consumer complaint letters or make free business calls to the offending company.

    ReplyDelete