本文整理汇总了PHP中Settings::frontend_profile_enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::frontend_profile_enabled方法的具体用法?PHP Settings::frontend_profile_enabled怎么用?PHP Settings::frontend_profile_enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::frontend_profile_enabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tpl_link_profile
/**
* Include the profile link template
* @param string $label Link text. Default: 'Profile'
* @param string $classes Classes to add to the <a> tag. Default: 'profile'
*/
function tpl_link_profile($label = null, $classes = 'profile')
{
if (is_null($label)) {
$label = __('Profile', 'theme');
}
if (Settings::frontend_profile_enabled()) {
$url = home_url('profile');
} else {
$url = admin_url('profile.php');
}
tpl('link', 'profile', array('url' => $url, 'label' => $label, 'classes' => $classes));
}
示例2: _user_register
//.........这里部分代码省略.........
exit;
}
// If required fields are missing
if (empty($params['password']) || empty($params['confirm_password']) || empty($params['data']['display_name']) || empty($params['data']['user_email'])) {
wp_redirect(home_url('register/error/incomplete'));
exit;
}
// If the passwords don't match
if (trim($params['password']) !== trim($params['confirm_password'])) {
wp_redirect(home_url('register/error/match'));
exit;
}
// Build a username
$username = '';
// If a first-name was supplied, use that
if (!empty($params['meta']['first_name'])) {
$username = esc_attr(strtolower(trim($params['meta']['first_name'])));
// If a last name was also supplied, append that with a '.'
if (!empty($params['meta']['last_name'])) {
$username .= '.' . esc_attr(strtolower(trim($params['meta']['last_name'])));
}
// If not a first name, maybe a last name was supplied, try that
} elseif (!empty($params['meta']['last_name'])) {
$username = esc_attr(strtolower(trim($params['meta']['last_name'])));
// Otherwise, use the display name, since thats required anyway
} else {
$username = esc_attr(strtolower(trim($params['data']['display_name'])));
}
// Make sure the username is unique
$username = self::uniquify_username($username);
// Create the user
$user_id = wp_create_user($username, esc_attr($params['password']), esc_attr($params['data']['user_email']));
// Build a user data array for saving additional metadata and user data.
// This might be repetative, but it allows for adding additional fields to the form
// without needing to modify this function
$user_data = array('ID' => $user_id);
// Add each data field in the form
foreach ($params['data'] as $key => $data) {
$user_data[$key] = esc_attr($data);
}
// Add each meta field in the form
foreach ($params['meta'] as $key => $meta) {
$user_data[$key] = esc_attr($meta);
}
// * Note, even though user data and user meta are stored separately in the database,
// They can be mixed together in the wp_update_user() function
// If registration email activation is required
// we will generate an activation key, and send a confirmation email.
// The user's account will not be activated until they login from the provided link.
// User "activation" is controlled by their assigned user role.
// A user with no assigned role is considered inactive.
if (Settings::registration_activation_required()) {
// Set their role to empty, to make their account inactive
$user_data['role'] = '';
// Save the additional data
wp_update_user($user_data);
// Generate an activation key for the user
$activation_key = self::get_user_activation_key($username);
// Build an email message
// TO DO: replace with content from option member_tools_settings[registration_email_content]
// replace {activation_link}, {user_display_name}, {user_email}, {site_title}
$message = '<p>';
$message .= sprintf(__('Thank you for registering on %s. To complete the process, please click the link below and login.', 'theme'), get_bloginfo('name'));
$message .= '</p><p>';
$message .= __('Activaye your registration here:') . "\r\n\r\n" . '<br>';
$message .= home_url('login/activate/' . rawurlencode($params['data']['user_email']) . '/' . $activation_key);
$message .= '</p>';
// Set the email headers
$headers[] = 'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>';
$headers[] = 'Content-Type: text/html; charset=UTF-8';
// Attempt to send the email
if (!wp_mail($params['data']['user_email'], __('Complete Your Registration', 'theme'), $message, $headers)) {
// Didn't work. Something went wrong with the email sending.
// The displayed error message contains a link to email the site admin,
// since this is not a user-generated error.
wp_redirect(home_url('register/error/email'));
exit;
} else {
// Worked. Redirect to the home page with a status message
// instructing them to check their email.
wp_redirect(home_url('status/registration-pending'));
exit;
}
// Registration activation setting is not enabled,
// so just log the user in right away
} else {
// Save the additional data
wp_update_user($user_data);
// Log the user in by setting their auth cookie
wp_set_auth_cookie($user_id);
// Redirect to either the profile page, or the admin
if (Settings::frontend_profile_enabled()) {
wp_redirect(home_url('profile/created'));
exit;
} else {
wp_redirect(admin_url());
exit;
}
}
}
示例3: tpl_link_logout
if (is_user_logged_in()) {
?>
<?php
if (Settings::frontend_login_enabled()) {
?>
<li><?php
tpl_link_logout();
?>
</li>
<?php
}
?>
<?php
if (Settings::frontend_profile_enabled()) {
?>
<li><?php
tpl_link_profile();
?>
</li>
<?php
}
?>
<?php
} else {
?>
<?php
if (Settings::frontend_login_enabled()) {
示例4: add_action
add_action('init', 'tpl_init');
add_action('admin_enqueue_scripts', 'tpl_admin_enqueue_scripts');
/**
* Required files
*/
// Plugin activation class
require get_template_directory() . '/includes/plugins/plugins.php';
// Settings class
require get_template_directory() . '/classes/settings.class.php';
// Main theme class
require get_template_directory() . '/classes/theme.class.php';
// Nav Menu Walkers
require get_template_directory() . '/classes/walkers/topbar-walker.class.php';
require get_template_directory() . '/classes/walkers/offcanvas-walker.class.php';
// Member tools class
if (Settings::frontend_login_enabled() || Settings::frontend_profile_enabled()) {
require get_template_directory() . '/classes/member-tools.class.php';
}
/**
* Theme has been activated
*/
function tpl_after_switch_theme()
{
/**
* Set the permalink structure to use postname
*/
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%postname%/');
}
/**
* WP Initialized