Skip to content

Instantly share code, notes, and snippets.

@bekarice
Last active February 4, 2019 23:17
Show Gist options
  • Save bekarice/4d4b30384cb3c9b1886a to your computer and use it in GitHub Desktop.
Save bekarice/4d4b30384cb3c9b1886a to your computer and use it in GitHub Desktop.
Insert WooCommerce Social Login buttons into the comment form
// Adds login buttons to the top of the comment form
function insert_wc_social_login_buttons() {
// Displays login buttons to non-logged in users with default text from settings + redirect back to the comment form
woocommerce_social_login_buttons( home_url( add_query_arg( array() ) ) . '#respond' );
// Optional: include this to display 'link account' buttons to logged in users + redirect back to the comment form
woocommerce_social_login_link_account_buttons( home_url( add_query_arg( array() ) ) . '#respond' );
}
add_action( 'comment_form_top', 'insert_wc_social_login_buttons' );
// Changes the login text from what's set in our WooCommerce settings so we're not talking about checkout here.
function change_social_login_text_option( $login_text ) {
// Only modify the text from this option if we're not in the admin or on a WooCommerce page
if( ! ( is_admin() || is_woocommerce() || is_cart() || is_checkout() ) ) {
$login_text = __( 'Create an account with social login in 12 seconds or complete the fields below.', 'WC_Social_Login' );
// Adjust the login text as desired
}
return $login_text;
}
add_filter( 'pre_option_wc_social_login_text', 'change_social_login_text_option' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment