Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wpf_crm_object_type', 'set_object_type');
- function set_object_type($object_type) {
- return 'WP_User__c';
- }
- //WP Fusion allow IP
- function unlock_by_ip( $can_access, $user_id, $post_id ) {
- if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
- // IP from share internet
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
- // IP passed from proxy
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- // Normal IP
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- if ( $ip == '13.111.63.226' ) {$can_access = true;} // Pardot
- if ( $ip == '104.236.230.137' ) {$can_access = true;} // Feedotter
- return $can_access;
- }
- add_filter( 'wpf_user_can_access', 'unlock_by_ip', 10, 3 );
- add_filter( 'wpf_user_can_access', 'wpf_allow_rss', 10, 3 );
- add_filter( 'wpf_user_can_access_archive', 'unlock_by_ip', 10, 3 );
- add_filter( 'wpf_user_can_access_archive', 'wpf_allow_rss', 10, 3 );
- // WP Fusion Magic Link login as real user
- // Disbale "Allow URL Login" in WP Fusion's settings for this to work properly.
- // URL format should be https://mysite.com?cid=123&key=KEY
- // Where "123" is the contact ID to be logged in, and KEY is the access key from the WPF settings
- function wpf_true_auto_login() {
- if( ! isset( $_GET['cid'] ) ) {
- return;
- }
- if( ! isset( $_GET['key'] ) || $_GET['key'] != wp_fusion()->settings->get( 'access_key' ) ) {
- return;
- }
- $contact_id = sanitize_text_field( $_GET['cid'] );
- $user_id = wp_fusion()->user->get_user_id( $contact_id );
- if( empty( $user_id ) || user_can( $user_id, 'manage_options' ) ) {
- return;
- }
- $user = get_user_by( 'id', $user_id );
- // Login
- wp_set_current_user( $user_id, $user->user_login );
- wp_set_auth_cookie( $user_id );
- do_action( 'wp_login', $user->user_login, $user );
- }
- add_action( 'after_setup_theme', 'wpf_true_auto_login' );
- // WP Fusion Exctra class Filter
- function custom_wpf_query_args( $query_args, $method ) {
- if ( 'get_contact_id' == $method ) {
- $query_args['q'] = str_replace( 'Email', 'Email__c', $query_args['q'] );
- }
- return $query_args;
- }
- add_filter( 'wpf_salesforce_query_args', 'custom_wpf_query_args', 10, 2 );
Add Comment
Please, Sign In to add comment