Add Fusion Page Builder support to New Create Custom Post Type in Avada theme

Hi WordPress Developer

Are you using WordPress top selling Avada theme ? To add some specif article / category post you want to create custom post type ? than might be my following sharing for Add Fusion Page Builder support to New Create Custom Post Type in Avada theme become helpful for you.

In Custom Post type new post Fusion Page builder by default not shows. than if you want to add it and use fusion page builder to add content in your newly created custom post type than you have to made following support related change in Fusion Core page builder plugin files.

Go to fusion-core plugin folder inside /wp-content/plugins/fusion-core/

than admin/class-pagebuilder.php

Now go to line 53

var $allowed_post_types = array(‘page’,’post’,’avada_faq’,’avada_portfolio’,’add_your_cpt’);

Get only level 1 sub category of category using get_categories in WP

If you want to get list of  only 1st level Sub Category of any specific category than with use of wordpress function get_categories  with set parent parameter value same as parent category you will get it.

get_categories(array(
‘child_of’ => $category_id,
‘parent’ => $category_id, // set here same category as you want to fetch only their 1st level category  on in depth child
));

Hide Dashboard menu from Subscriber in WP

If you want hide Dashboard menu from Subscriber role user and just want to show their Profile in back end access than its easy to achieve by adding few lines below code in your active theme functions.php file .
with use of this script you no need to use any plugins for hide Dashboard from Subscriber user. its easy to achieve without use of any plugin.

 

function wplshide_custom_admin_dashboard_links() {

global $parent_file;
if ( ! current_user_can( ‘edit_posts’) && is_user_logged_in()) {
remove_menu_page( ‘index.php’);
remove_menu_page( ‘separator1’ );

if ( ‘index.php’ == $parent_file ) {
if ( headers_sent() ) {
echo ‘<meta http-equiv=”refresh” content=”0;url=’ . admin_url( ‘profile.php’ ) . ‘”>’;
echo ‘document.location.href=”‘ . admin_url( ‘profile.php’ ) . ‘”‘;
} else {
if ( wp_redirect( admin_url( ‘profile.php’ ) ) ) {
exit();
}
}
}
}

}

add_action( ‘admin_head’, ‘wplshide_custom_admin_dashboard_links’ );

jQuery Script – href # target navigate like one page template use

Using jQuery script move navigation to particular section on same page when click on anchor link which href attribute set like  href=”#about”

Html

<a href=”#about” class=”page-scroll”>About Us</a>

About us Html Section

About us content area

jQuery Script

jQuery(function ($) {
‘use strict’;

jQuery(function ($) {
‘use strict’;
$(function(){
$(‘a.page-scroll’).bind(‘click’, function(event) {
var $anchor = $(this);
$(‘html, body’).stop().animate({scrollTop: $($anchor.attr(‘href’)).offset().top -62}, 1000);
event.preventDefault();
});

});

if (window.location.hash){
$(‘html, body’).stop().animate({scrollTop: $(window.location.hash).offset().top -62}, 1000);
}

});

Add addtional CSS JS script file in child theme

add_action(‘wp_enqueue_scripts’, ‘ls_head_styles_scripts’, 20 );
function ls_head_styles_scripts() {
wp_register_script(‘ls-custom-script’, get_stylesheet_directory_uri().’/js/ls_custom.js’,array(),”,true);
wp_enqueue_script(‘ls-custom-script’);
wp_localize_script(‘ls-custom-script’, ‘ls_ajax_script’, array( ‘lsajaxurl’ => admin_url( ‘admin-ajax.php’)));

// localize lsajaxurl variable to use in jQuery ajax  post to post request on wordpress

to use it call ls_ajax_script.lsajaxurl
}

Restrict WP User from WP backend logging and profile edit

Restrict WordPress user from Wp back end admin panel login and also restrict from edit profile in back end side.

 

just put below few line code in your active theme funcstions.php file

<?php

add_action( ‘admin_init’, ‘custom_wpadmin_blockusers_init’ );
function custom_wpadmin_blockusers_init() {
if ( !current_user_can( ‘activate_plugins’ ) ) {
wp_redirect( home_url() );
exit;
}
}
show_admin_bar(false);

?>

Wp Backend side add additional field in User profile add edit

To add additional field in WordPress admin backend side User profile add edit screen add below scripting in your current using Wp theme functions.php file

 

<?php

/* start Back end extra User profiel field */

add_action( ‘show_user_profile’, ‘extra_user_profile_fields’ );
add_action( ‘edit_user_profile’, ‘extra_user_profile_fields’ );
add_action( “user_new_form”, “extra_user_profile_fields” );

function extra_user_profile_fields( $user ) {
$auto_approve = get_the_author_meta( ‘auto_approve’, $user->ID);
$user_verify_status = get_the_author_meta( ‘user_verify_status’, $user->ID);
?>
<h3><?php _e(“Extra profile information”, “blank”); ?></h3>
<table class=”form-table”>
<tr>
<th><label for=”auto_approve”><?php _e(“Auto Approve Post”); ?></label></th>
<td>
<select name=”auto_approve” id=”auto_approve” style=”width:180px”>
<option value=”0″ <?php selected( $auto_approve, 0); ?>>No</option>
<option value=”1″ <?php selected( $auto_approve, 1); ?>>Yes</option>
</select>
</td>
</tr>
<tr>
<th><label for=”user_verify_status”><?php _e(“Ac Verification”); ?></label></th>
<td>
<select name=”user_verify_status” id=”user_verify_status” style=”width:180px”>
<option value=”inactive” <?php selected( $user_verify_status, ‘inactive’); ?>>Not Verified</option>
<option value=”active” <?php selected( $user_verify_status, ‘active’); ?>>Verified</option>
</select>
</td>
</tr>

</table>
<?php }

add_action( ‘personal_options_update’, ‘save_extra_user_profile_fields’ );
add_action( ‘edit_user_profile_update’, ‘save_extra_user_profile_fields’ );
add_action( ‘user_register’, ‘save_extra_user_profile_fields’ );

function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( ‘edit_user’, $user_id ) ) { return false; }
update_user_meta( $user_id, ‘auto_approve’, $_POST[‘auto_approve’] );
update_user_meta( $user_id, ‘user_verify_status’, $_POST[‘user_verify_status’] );
}

 

?>