latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

How to update Custom Capability in batch

Home Forums Community Forum How to update Custom Capability in batch

This topic contains 1 reply, has 2 voices. Last updated by  Raam Dev 4 years, 1 month ago.

Topic Author Topic
Posted: Thursday Nov 22nd, 2012 at 11:34 pm #32381
Lan
Username: bigrice

Hello, I hope to update Custom Capability (my WP user name) in batch to some of my current clients, so that they can access certain pages I created.

Can you please show me a few lines of codes how I can assign Custom Capability to current users in batch? (I can do a SQL query to pull out the WP users I want to assign Custom Capability to, and then?) Many thanks.

Any key code lines I’m missing?

$user = get_userdata($user_id);
$ccap = “access_s2member_ccap_”.$my_user_name;
$user->add_cap($ccap);

  • This topic was modified 4 years, 1 month ago by  Lan.
  • This topic was modified 4 years, 1 month ago by  Lan.
  • This topic was modified 4 years, 1 month ago by  Lan.
  • This topic was modified 4 years, 1 month ago by  Lan.

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Friday Nov 23rd, 2012 at 1:47 pm #32436
Raam Dev
Username: Raam
Staff Member

Hi Lan,

The WordPress Codex Function Reference page for add_cap() has an example for adding a ccap to a user:

//to add capability to specific user
$user = new WP_User( $user_id );
$user->add_cap( 'can_edit_posts');
Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.