Created
September 23, 2016 08:40
-
-
Save vince844/383dcbdca92409484815d1dec2ef0b67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CREAZIONE NUOVA PAGINA UTENTE E ATTRIBUZIONE DELLE CAPABILITIES | |
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'] = $username; // Il permalink della pagina | |
$post['post_type'] = 'page'; // Specifica che sarà una pagina ad essere creata | |
$post['comment_status'] = 'closed'; // Rimuove i commenti dalla pagina | |
$post['post_content'] = esc_attr($username.' - Benvenuto nel pannello di controllo, da qui potrai accedere ai tuoi dati personali e tanto altro. Stiamo aggiornando la tua pagina!'.$userid); // Descrizione e messaggio di benvenuto | |
$post['post_author'] = $username; | |
$post['post_status'] = 'publish'; //status | |
$post['post_title'] = 'Pagina di '.$username; // Specifica il tiolo della pagina | |
$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_user.php'); // Attribuisce un tema alla pagina creata | |
$user = new WP_User($user_id); | |
$user->add_cap("access_s2member_ccap_$username"); // Popola la custom capability dell'utente con l'username | |
update_post_meta($post_id, 's2member_ccaps_req', "$username"); // Popola la custom capability della pagina con l'username | |
$new_options = Array(); // s2member array per livello di sicurezza | |
$new_options["ws_plugin__s2member_level0_pages"] = $post_id; // Imposta livello 0 per questa nuova pagina | |
c_ws_plugin__s2member_menu_pages::update_all_options ($new_options, true, false, array ("page-conflict-warnings"), true); // aggiorna s2member | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment