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.

Updating page meta data

Home Forums Community Forum Updating page meta data

This topic contains 7 replies, has 2 voices. Last updated by  Andrew Hodges 3 years, 9 months ago.

Topic Author Topic
Posted: Tuesday Mar 19th, 2013 at 11:03 am #45169

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Thursday Mar 21st, 2013 at 2:44 am #45294
Username: Bruce
Staff Member

Thank you for your inquiry.

The best way to find what s2Member uses for deciding if a User can see a Post would be to look in this file:


I can tell you that s2Member does store the info for the required Custom Capabilities in a serialized array in the post meta field s2member_ccaps_req, which you have set up in in your example. This is set up the same way in this file (line 118):


If you continue to have problems, I would recommend first checking that the Post Meta field is being populated correctly when you call on the update_post_meta() function.

Posted: Thursday Mar 21st, 2013 at 8:54 am #45328

Thank you for the reply.

Yes I have seen the class. Maybe I should have been clearer. It is s2member_level_req that seems to be my problem. This caused my original routine to fail. Full function below.

As you say ccaps_req works ok but level_req does not seem to work. Now I may not be reading your code correctly but I have tried passing ‘0’ to it, even the complete string to it but I do not seem able to populate the Page Level Restriction. The Require Custom Capabilities works fine.

Can you confirm I have the correct operator level_req and what needs passing to establish level 0 access?

// Add page after new user registered
    add_action('user_register', 'registration_newpage');
    function registration_newpage($user_id) {
        $user_info = get_userdata($user_id);
        $username = $user_info->user_login;
        $post = array();
        $post['post_name']    = 'Members-Page-for-'.$username; // The name (slug) for the page
        $post['post_type']    = 'page'; //sets type
        $post['post_content'] = esc_attr($username.' - This page was created for you and any messages that we need to send you with regards to any products, services or changes to your membership will be posted here.'.$userid);
        $post['post_author']  = $username;
        $post['post_status']  = 'publish'; //status
        $post['post_title']   = 'Members Page for '.$username;
        $post_id = wp_insert_post ($post);
        if (!$post_id) {
            wp_die('Error creating user page');
        } else {
            update_post_meta($post_id, '_wp_page_template', 'page-members.php');
            $user = new WP_User($user_id);
            update_post_meta($post_id, 's2member_ccaps_req', 'ahodges');
            update_post_meta($post_id, 's2member_level_req', '0');        //this does not work
Posted: Friday Mar 22nd, 2013 at 5:45 pm #45522
Username: Bruce
Staff Member

Thanks for the follow-up. Sorry for the delay in response.

s2Member handles Level restrictions differently. If you’d like to do that, I’d personally recommend just updating a separate option in your installation, and hooking into the ws_plugin__s2member_check_specific_post_level_access to decide when to block access to a post based on this option. If, however, you’re hoping to do it just as s2Member does it, you’ll need to put the Post’s ID into one an s2Member global variable. You can find an example of a time s2Member does this in this file (line 57):

Posted: Friday Mar 22nd, 2013 at 8:04 pm #45533

I will have a look at that, thanks. But whilst I am doing so I thought I was following the method described in one of your video’s (Portal) to make a unique page for a member with unique content for that member.

I think what you have described would give members access dependant on a condition or conditions I want only this member to have access to this. Do you think the video is now out of date or theres a better way?

Posted: Saturday Mar 23rd, 2013 at 12:26 pm #45563

I am going to have a little moan now. When purchasing s2member you say that the plugin and code is thoroughly documented. You have also said in your video presentation that ‘this is the method’ and with a little look at the API scripting documentation and a little php you can do this …..

Where is the documentation? Failing no documentation simply pointing someone to your php file is not support or a remedy to the lack of documentation.

Now I may be very poor at php but it has taken me 1.5hrs to set up debugging in one of your classes to find the answer to the question. Not great documentation not great support!

by the way so everyone can benefit from my 1.5hrs in relation to your video ‘portal’ the answer appears to be:

$new_options = Array(); // s2member array for security level
$new_options["ws_plugin__s2member_level0_pages"] = $post_id; // set Level0 for this Page
c_ws_plugin__s2member_menu_pages::update_all_options ($new_options, true, false, array ("page-conflict-warnings"), true); // s2member update

If only you had told me that.

Posted: Sunday Mar 24th, 2013 at 7:36 pm #45610


I now cannot login to the site. I don’t know if its coincidence or not but the login page keeps redirecting to failed log gin where ever its called from.

If I disable s2member via ftp I can get back in. Is this related? Your URGENT comments please. By the way I have looked at your knowledge and trouble shooting articles.

Posted: Monday Mar 25th, 2013 at 7:33 am #45632

I have debugged the error appears to be un-related.

Viewing 7 replies - 1 through 7 (of 7 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.